0

I have a spring boot application,

  • Packaged as war file
  • Deployed in a tomcat 9.x
  • The web app is calling third-party web-services using SOAP.

My problem was how to show the SOAP logs specifically in Tomcat container, because I can show the logs in Spring boot using the following code in Application's main method

 System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
    System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
    System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold", "999999");

But this didn't work in tomcat server. I have found the below post to build a Soap Handler to log requests:

https://stackoverflow.com/a/27468517/716865

What happened is the third-part responded with invalid name space error

Muhannad A.Alhariri
  • 3,702
  • 4
  • 30
  • 46

1 Answers1

1

After long investigation, I have found the following simple solution:

  1. Edit yout catalina.sh/catalina.bat file which can be found in your tomcat installation
  2. Add the following lines or append to CATALINA_OPTS:

    CATALINA_OPTS="-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true -Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold=999999"

  3. Restart your tomcat server

  4. Call the webservice from the web app, you will find all soap requests fully logged

Be aware, that this could lead to security concerns if the soap requests/response has sensitive data.

I believe there could be better solutions than mine, but this workss perfectly for me without adding any extra piece of code.

Muhannad A.Alhariri
  • 3,702
  • 4
  • 30
  • 46