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>"
Asked
Active
Viewed 2,215 times
-1

Manikandan
- 121
- 11
-
Are you familiar with [XPath](https://www.w3.org/TR/1999/REC-xpath-19991116/)? – VGR Mar 06 '18 at 15:24
-
No VGR, I am new to SOAP web service. yet to learn – Manikandan Mar 06 '18 at 17:14
2 Answers
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
-
1Yes 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