Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8980975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:13:06+00:00 2026-06-15T20:13:06+00:00

SOAPMessage has writeTo() method which is used to print its content into a stream.

  • 0

SOAPMessage has writeTo() method which is used to print its content into a stream.
But How I can write SOAPMessage content into StringBuffer?

code line “message.writeTo(System.out);” has to be modified..

public boolean handleMessage(SOAPMessageContext smc) {
     StringBuffer sbuf = new StringBuffer();
     sbuf.append("\n------------------------------------\n");
     sbuf.append("In SOAPHandler " + HandlerName + ":handleMessage()\n");

     Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

     if (outboundProperty.booleanValue()) {
        sbuf.append("\ndirection = outbound ");
     }
     else {
        sbuf.append("\ndirection = inbound ");
     }

     SOAPMessage message = smc.getMessage();      
     try {
        sbuf.append("\n");
        sbuf.append(message.toString());         
        //message.writeTo(System.out);         
        sbuf.append("\nMessage Desc:");         
        sbuf.append("\n");
     }
     catch (Exception e) {
        sbuf.append("Exception in SOAP Handler: " + e);
     }

     sbuf.append("Exiting SOAPHandler " + HandlerName + ":handleMessage()\n");
     sbuf.append("------------------------------------\n");
     logger.debug(sbuf.toString());
     return true;
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:13:08+00:00Added an answer on June 15, 2026 at 8:13 pm

    OK I have solved the question. Modified code block is as follow.

      public boolean handleMessage(SOAPMessageContext smc) {
         StringBuffer sbuf = new StringBuffer();
         sbuf.append("\n------------------------------------\n");
         sbuf.append("In SOAPHandler " + HandlerName + ":handleMessage()\n");
    
         Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    
         if (outboundProperty.booleanValue()) {
            sbuf.append("\ndirection = outbound ");
         }
         else {
            sbuf.append("\ndirection = inbound ");
         }
    
         SOAPMessage message = smc.getMessage();      
         try {
            sbuf.append("\n");
            sbuf.append(message.toString()); 
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            message.writeTo(baos);                     
            sbuf.append("\nMessage Desc:"+baos.toString());         
            sbuf.append("\n");
         }
         catch (Exception e) {
            sbuf.append("Exception in SOAP Handler: " + e);
         }
    
         sbuf.append("Exiting SOAPHandler " + HandlerName + ":handleMessage()\n");
         sbuf.append("------------------------------------\n");
         logger.debug(sbuf.toString());
         return true;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a SOAPMessage to a byte Array so i can encrypt
currently making a SOAP request using Java's SOAPConnectionFactory and SOAPConnection 's .call() method, which
I have created a simple web service which return a response, but I am
Hoh can I create a SOAPMessage from a String representation of an entire SOAP
I have an ASP.NET (1.1) web service which authenticates clients using a SoapExtension.ProcessMessage(SoapMessage) override
I'm working with SOAP using the javax.xml.soap package. I have a javax.xml.soap.SOAPMessage object that
I have a SOAP message (see below). Using Xpath, how can I extract the
This has been really frustrating for me so I'll try explain what I know
Im not sure about what authentification method I should use for my webservice. I've
Using Visual Studio 2008, I setup a client that uses Web Services. It has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.