Originally posted by anubechara Gupta:
Insert WS-Addressing tags such as <wsa:Action>,<wsa:MessageID>, <wsa:ReplyTo> and <wsa:To> in my soap request.
Probably the first thing
you should try is to insert the necessary elements in a JAX-RPC handler in the client's outgoing handler chain. You still have to modify the SOAP message with
SAAJ.
This example shows a client side handler adding a SOAP header to the SOAP request.
Support for J2EE Web Services in WebSphere Studio Application Developer V5.1 -- Part 3: JAX-RPC Handlers
Process attachments using JAX-RPC handlers
Access SOAPMessageContext from the service consumer
On the service consumer side, there is also no direct way to access SOAPMessageContext. The only way of doing this is by setting or getting properties on the javax.xml.rpc.Stub interface, defined as part of the JAX RPC standard. Every port implementation class (Listing 2) generated by Application Developer can be type-casted to the Stub interface, thus allowing for setting and getting Stub's properties.
Theoretically you should be able to call the
javax.xml.rpc.Stub setProperty method on your Port object with your wsaAction, wsaMessageID, wsaReplyTo and wsaTo
String values (or even
javax.xml.rpc.holders.StringHolder)
before you call the web method on the port (i.e. single
thread only). The stub properties are copied to the SOAPMessageContext where the handler can retrieve the values and create the elements in the outgoing request as necessary.
The advantage of the StringHolder is that holder value changes (via the value field) by the handler (example: you extract header values in handleResponse) are available after the web method returns. With simple Strings this would not work as the SOAPMessageContext properties
are not copied back to the Stub after the incoming handler chain is finished. Using a single Hashmap as a property for multiple name/value pairs would have the same effect.
How to create a simple JAX-RPC handler [ November 18, 2008: Message edited by: Peer Reynders ]