且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java JAX-WS Web服务客户端:如何记录日志请求&响应xml?

更新时间:2023-09-11 23:16:16

如果你使用这种方法它会开始工作:

  binding.setHandlerChain(handlerList); 

因此,首先用



$ b binding.getHandlerChain();

然后将您的元素添加到列表中并且毕竟

  setHandlerChain(); 


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?

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();