|
|
||
Rama Pulavarthi's Blog
«Extending JAX-WS With Annotations |
Main
| Useful Goodies for Web Service Developers in JAX-WS 2.1 RI »
Using Addressing With JAX-WS Clients without WSDLPosted by ramapulavarthi on January 21, 2007 at 01:54 AM | Comments (3)Addressing can be enabled on client by having a wsdl with <wsaw:UsingAddressing/> in the wsdl definitions or enabling AddressingFeature while creating the client proxy. In EA3, Although Addressing is enabled, for it to work the clients (esp. Dispatch) have to be created with wsdl, otherwise Addressing headers are not sent automatically by the JAX-WS Runtime. The reason was wsa:Action header which is mandatory comes from wsdl either it be explicitly specified or implicitly computed using wsdl:operation's definition. All other addressing headers can be computed without WSDL or assume default values. The same wsa:Action header is used as SOAPAction http header. JAX-WS API provides way to set SOAPAction header in the message context. Using this mechanism, Recently I made a fix to use Addressing runtime. Now for Addressing to work, WSDL is no more needed. All you need to do is set BindingProvider.SOAPACTION_URI_PROPERTY property. An example below shows its usage. Service service = Service.create(SERVICE_QNAME); service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:8080/service/example"); Dispatch<Source> dispatch = service.createDispatch(PORT_QNAME, Source.class, Service.Mode.PAYLOAD, new AddressingFeature()); dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true); dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"http://example.com/action/dothis"); dispatch.invoke(requestSrc); If you set these properties, JAXWS Runtime takes care of sending all the addressing headers in the SOAP Message. These are the messages with Addressing disabled(default)/enabled with the dispatch client. Addressing not enabled: <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <addNumbers xmlns="http://example.com/"> <number1>10</number1> <number2>10</number2> </addNumbers> </S:Body> </S:Envelope> </S:Body> </S:Envelope> Addressing enabled: <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header> <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/service/example</To> <Action xmlns="http://www.w3.org/2005/08/addressing">http://example.com/action/dothis</Action> <ReplyTo xmlns="http://www.w3.org/2005/08/addressing"> <Address>http://www.w3.org/2005/08/addressing/anonymous</Address> </ReplyTo> <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:45c2f4eb-48ea-4 be4-8376-05535313ef9f</MessageID> </S:Header> <S:Body> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <addNumbers xmlns="http://example.com/"> <number1>10</number1> <number2>10</number2> </addNumbers> </S:Body> </S:Envelope> </S:Body> </S:Envelope> Hope this makes it easy to use Addressing with Dispatch. Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment
| ||
|
|