Search code examples
javasoapjax-ws

Cannot log JaxWs client xml messages


I generated a SOAP client from WSDL using wsimport (version "2.2.9") and I'm using it in a Java 8 application.

I'd like to trace XML messages sent/received by the client but I cannot find a working solution...

I tried using this approach this way:

public class TestClass {
    public static void main(String[] args) {
        System.setProperty("com.sun.xml.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.client.HttpTransportPipe.dump", "true");
        System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");


        WSService wsService = new WSService();
        WSSoap soapService = wsService.getWSSoap();
        ServiceResponse response = soapService.callServiceMethod();
    }
}

The request is executed correctly, but I cannot find any XML traced on standard output. What's wrong with this code?


Solution

  • For debugging soap request and responses in jetty on eclipse you can do the following.

    1. Select your project in project explorer and right click it.
    2. Under Run As, click Run Configurations
    3. Your app should already show as a Jetty Webapp and the name of the project will be listed underneath Jetty Webapp. On the arguments tab, add the following to the JVM arguments section
      -Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
      -Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true
      -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
      -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true
    4. Click run, any interaction your application now makes with a web service will be logged

    This was tested with a dynamic web project that had a servlet which called the webservice on load of the servlet.

    Screen shot of settings: enter image description here