Printing a SOAP response

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 31
Reputation: kinger29 is an unknown quantity at this point 
Solved Threads: 1
kinger29 kinger29 is offline Offline
Light Poster

Printing a SOAP response

 
0
  #1
Jul 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,619
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Printing a SOAP response

 
0
  #2
Jul 19th, 2009
Try writeTo method of the SOAPMessage abstract class:
message.writeTo(System.out);
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 31
Reputation: kinger29 is an unknown quantity at this point 
Solved Threads: 1
kinger29 kinger29 is offline Offline
Light Poster

Re: Printing a SOAP response

 
0
  #3
Jul 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,619
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Printing a SOAP response

 
0
  #4
Jul 20th, 2009
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.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC