1

I have a web service Client class that establishes a connection with the destination server using the wsdl url. This class uses JaxWsProxyFactoryBean and the WSS4JOutInterceptor to establish a secure connection. I would like to see the SOAP request generated by my code and response generated from the server.

I have tried including the following options when I run my jar from the command line

-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 

I am using log4j for logging and all the messages get written to a custom file. How can I dump the SOAP request/responses to this same file using command line options?

Do I have to make any code changes to the Client class to achieve this?

Thanks for the help.

Sapphire
  • 1,107
  • 8
  • 20
  • 35

1 Answers1

1

I had to add the following lines to the class that creates a SOAP request:

LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
factory.getInInterceptors().add(loggingInInterceptor);
factory.getOutInterceptors().add(loggingOutInterceptor);

I also had to update my cxf client to the latest version from Apache i.e. 2.7.12. This printed out the SOAP headers to the console.

Sapphire
  • 1,107
  • 8
  • 20
  • 35