1

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?

davioooh
  • 23,742
  • 39
  • 159
  • 250
  • This should 100% work for you `com.sun.xml.ws.transport.http.HttpAdapter.dump, "true"` as it worked for me. What App server are you using? – JGlass Apr 26 '18 at 17:16
  • Get it working? – JGlass Apr 27 '18 at 13:42
  • @JGlass not yet... the property you suggest isn't working for me... :| My project is running on Jetty, but I also tested it on a standalone (console) application... – davioooh May 03 '18 at 07:20
  • Got it working, had to install jetty and create a sample project. I'll post an answer in a few. Tell me you are using eclipse? – JGlass May 03 '18 at 15:09

1 Answers1

0

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

JGlass
  • 1,427
  • 2
  • 12
  • 26