943,718 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4507
  • Java RSS
Jul 19th, 2009
0

Printing a SOAP response

Expand Post »
How do you print a SOAP response? I have been trying to do the following but its not printing the actual soap message. Its just giving me some sort of description.

SOAPMessage reply = connection.call(message, destination);
String myreply = reply.getSOAPPart().getContent().toString();
Last edited by kinger29; Jul 19th, 2009 at 3:24 pm.
Similar Threads
Reputation Points: 11
Solved Threads: 2
Light Poster
kinger29 is offline Offline
35 posts
since Mar 2008
Jul 19th, 2009
0

Re: Printing a SOAP response

Try writeTo method of the SOAPMessage abstract class:
message.writeTo(System.out);
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jul 19th, 2009
0

Re: Printing a SOAP response

Thanks for the quick response. The problem I was having using the WriteTo method is I need to store the SOAP message in a string to output to a JTextArea. Is there an easy way to do this? Sorry I am still new to java.
Reputation Points: 11
Solved Threads: 2
Light Poster
kinger29 is offline Offline
35 posts
since Mar 2008
Jul 20th, 2009
0

Re: Printing a SOAP response

There are two ways:
- You can either call the getSOAPBody() and getSOAPHeader() methods and manually construct the entire pretty-printed SOAP message
- Use the ByteArrayOutputStream class instance and pass it to the writeTo() method. Retrieve the resulting string using the getString() method or use new String(outputStream.getBytes(), "UTF-8") in case you are using a specific encoding.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: search engine in java
Next Thread in Java Forum Timeline: Thinking In Java?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC