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();
8 Years
Discussion Span
Last Post by ~s.o.s~

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.


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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.