Java JAX-WS web-service client: how log request & response xml?

EugeneP picture EugeneP · May 11, 2010 · Viewed 18.4k times · Source

I created an implementation of LoggingHandler that implements SOAPHandler<SOAPMessageContext>

It should log whenever handleMessage triggers (and it is never called in my case)

MyService service = new MyService();
MyServicePort port = service.getPortType();

now I try this:

BindingProvider bindingProvider = (BindingProvider)port;
bindingProvider.getBinding().getHandlerChain().add(new LoggingHandler());

I do not see any request / response xml though.

Can you suggest any solution? Maybe there's another way to see output and request XML?

Answer

EugeneP picture EugeneP · May 11, 2010

It starts working if you use this method:

binding.setHandlerChain(handlerList);

So, first initialize this list with

binding.getHandlerChain();

then add your element to the list and after all

setHandlerChain();