Using spring ws to get the StreamResult as below
StreamSource source = new StreamSource(new StringReader(MESSAGE));
StreamResult result = new StreamResult(System
If none of these works, try this
System.out.println(result.getOutputStream().toString());
Assuming you have this kind of structure ,
private static StreamResult printSOAPResponse(SOAPMessage soapResponse) throws Exception {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = soapResponse.getSOAPPart().getContent();
System.out.print("\nResponse SOAP Message = ");
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
return result;
}
You can try this way , although the same thing, wanted to point it out clearly
System.out.println(printSOAPResponse(soapResponse).getOutputStream().toString());