We message driven bean endpoints. They do receive a SOAPMessage that can be serialized into a string. Is this what you need?
I need the serialization at the client side, not server side. I need to convert the SOAP call to String and sent it via JMS to ESB or for example I need only to display what message would be sent without actually sending it.
A client side handler can do this for you. You would return false from handleMessage and do with the SOAP message whatever you like.
Thanks for the response, this approach works. But I hit another problem. I am also applying WS-S rules on message and in handler I am getting plain SOAP without WSS rules applied. Is it possible that I will receive message even with security handlers and encrypted?
It simply depends on the order of the handlers. i.e. if your handler comes before the wsse handler you won't have wsse and vice versa
I tried two approaches
1) use typecasting to StubExt and set security config. Then security works OK, but my handler is called before message is enriched with security elements
2) I used handlerChain.add(new org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerClient()); In this case my handler was called after the security one. The WS was successfully invoked but when the service returned result, the client thrown an exception SOAP request exception
[testng] org.jboss.ws.WSException: Cannot find child element: return
Apparently the client did not processed WSS headers
So I am looking for one of the two solutions
1) Force client to first process security set via StubExt and then the process handlers (preferred)
2) Or enable the second approach working. maybe I need to add another handler that will process the response separately?
Thanks in advance
An explanation that may help, hope it's not too late.
The reason why your first approach results in your handler being called before the wsse one is that the latter is configured as a post-handler while yours is an endpoint-handler. You would need your handler to be a post-handler, however afaik this can only be achieved editing the jbossws configurations in standard-jaxws-client-config.xml.
Speaking of the second approach, where did you do that call? where is the handlerChain instance from?
can only be achieved editing the jbossws configurations in standard-jaxws-client-config.xml.
you can also supply your own config file
thanks for your answers. I have done fast and dirty solution
// Generate the SOAP xml StringWriter messageString = new StringWriter(); List<Handler> handlerChain = bindingProvider.getBinding().getHandlerChain(); handlerChain.add(new org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerClient()); handlerChain.add(new TestHandler(messageString)); bindingProvider.getBinding().setHandlerChain(handlerChain); UserType userType = new UserType(); userType.setMsg(TEST_MESSAGE); UserType retObj = hello.echoUserType(userType); // Actually call the WS bindingProvider.getBinding().setHandlerChain(new ArrayList<Handler>()); ((StubExt) hello).setSecurityConfig("jboss-wsse-client.xml"); ((StubExt) hello).setConfigName("Standard WSSecurity Client"); retObj = hello.echoUserType(userType);
This approach worked albeit it is really crude