I am using WebServiceTemplate to consume SOAP response. For logging purpose i need to get the SOAP response in string.
For example , "<envelope><body><name>xyz</name></body></envelope>"
You can achive it like below with WebServiceTemplate:
ByteArrayOutputStream bytArrayOutputStream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(bytArrayOutputStream);
wsTemplate.sendSourceAndReceiveToResult(defautUri, source, result);
final String reply = new String(bytArrayOutputStream.toByteArray())