Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Spring WebServices log all SOAP requests?

I need all SOAP requests logged in the CommonLogFormat (see http://en.wikipedia.org/wiki/Common_Log_Format), plus the duration (the amount of time it takes to process the request).

What's the best way to do this? It looks like it's possible to configure log4j for Spring WebServices but will it log all the values I'm interested in? http://pijava.wordpress.com/2009/12/04/spring-webservice-soap-requestresponse-logging-with-log4j/

EDIT: We're actually using SLF4J, not Log4j. Also, it looks like it's possible to do this by configuring the PayloadLoggingInterceptor: http://static.springsource.org/spring-ws/site/reference/html/server.html#server-endpoint-interceptor

But I am not sure where the log messages will go. I added that interceptor to our interceptors and I don't see any log messages.

like image 339
Nate Reed Avatar asked Aug 18 '11 14:08

Nate Reed


People also ask

How do I track a SOAP request?

In SOAP web service, each HTTP request or response encapsulates a SOAP envelope, these messages are easy to trace by using Eclipse IDE, build-in “TCP/IP monitor” tool. The idea is host another server in between the client and server to perform port forward function to intercept the HTTP traffic.

How do I log into Soapmessage?

ByteArrayOutputStream bout = new ByteArrayOutputStream(); message. writeTo(bout); String msg = bout. toString("UTF-8"); Now String msg has the soap message and you can log it.

How do you call a SOAP Web service from REST API in spring boot?

Steps to Consume a SOAP service :Create spring boot project and Get the WSDL from the provider . Convert the WSDL to Stub. Understand the request ,response and the types ,operations using any tool like SOAP UI. Form the request object by mapping data and call the soap uri with marshal the java objects as XML.


2 Answers

For Spring Boot project adding below in application.properties worked for me:

logging.level.org.springframework.web=DEBUG logging.level.org.springframework.ws.client.MessageTracing.sent=DEBUG logging.level.org.springframework.ws.server.MessageTracing.sent=DEBUG logging.level.org.springframework.ws.client.MessageTracing.received=TRACE logging.level.org.springframework.ws.server.MessageTracing.received=TRACE 
like image 92
Arpit Aggarwal Avatar answered Sep 23 '22 14:09

Arpit Aggarwal


You can use this to log the raw paylod of incoming and outgoing web service calls.. I'm not sure how to log how long the webservice communication took.

   <!-- Spring Web Service Payload Logging-->    <logger name="org.springframework.ws.client.MessageTracing">     <level value="TRACE"/>     </logger>    <logger name="org.springframework.ws.server.MessageTracing">     <level value="TRACE"/>     </logger> 

Additional details can be found at http://static.springsource.org/spring-ws/site/reference/html/common.html#logging

like image 29
JustinKSU Avatar answered Sep 21 '22 14:09

JustinKSU