views:

29

answers:

1

I am developing a web service, using Metro 2.0 and Tomcat 6, and I have a requirement to be able to log the XML payload of the request and response of a web method for development/support reasons. The payload would only be logged when in debug mode.

The Web Service uses a servlet implementation (com.sun.xml.ws.transport.http.servlet.WSServlet and .WSServletContextListener classes), if that affects the answer.

Is this even possible?

Thanks in advance, Andy

+1  A: 

Try setting these system properties:

-Dcom.sun.metro.soap.dump=true
-Dcom.sun.xml.ws.assembler.client=true

The SOAP messages go to system out, which I believe Tomcat logs.

Thorbjørn Ravn Andersen
I have set these 2 values by way of System.setProperty() method and nothing is being logged. I am running tomcat within eclipse (which of course runs the tomcat instance inside the WST plugin directory) and invoking it using the Web Services Explorer. There are no files in the workspace/plugins/.../logs directory and nothing new on the console. Am I doing something wrong?
trojanfoe
They need to be defined in the invocation of the JVM. I have too seen that using System.setProperty did not work.
Thorbjørn Ravn Andersen
OK many thanks!
trojanfoe
Did it work to your satisfaction?
Thorbjørn Ravn Andersen
Yeah it's working fine thanks - I need to create scripts to start Tomcat in release/debug mode and I'm now looking how to control the debug setting of Logback using a similar mechanism.... cheers -A
trojanfoe
logback supports "tasting" on system properties and conditional evaluations.
Thorbjørn Ravn Andersen
There is now the possibility that I need the XML payload of the request and response in order to log it directly to the database! A .net programmer at work thinks I can get this using an interceptor or message handler? Is that true when using Metro 2?
trojanfoe
I do not immediately know. I would suggest opening a new question.
Thorbjørn Ravn Andersen