-1

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>"

Manikandan
  • 121
  • 11

2 Answers2

0

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())
Cesar Canassa
  • 18,659
  • 11
  • 66
  • 69
Bhushan Uniyal
  • 5,575
  • 2
  • 22
  • 45
-1

If you using spring, you can add log using log4j in interceptor. Log4j can write to file or even db. I hope its help you.

FPratama
  • 14
  • 3
  • 1
    Yes but here major part is convert that soap response received in Java object to XML string as I mentioned above. – Manikandan Mar 06 '18 at 14:05