This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is there a way to correlate the request and response from a service call in a soap handler?
I am storing the request and respose soap messages (xml fragments) in a database for logging purposes and I need to track the pairs (request, response).
I'll try to describe a model that will let you correlate requests and responses from a web service client. It includes making modifications to both the client and the web service itself.
Web Service Client In the client, before sending the request, insert a correlation id for the request into the MessageContext of the request.
In the client handler, retrieve the correlation id from the MessageContext and insert into a header with the ultimate receiver as actor (SOAP 1.1)/role (SOAP 1.2).
When the client receives a response, the handler retrieves the appropriate header block containing the correlation id and inserts it into the MessageContext of the response.
The code in the client can then retrieve the correlation id from the MessageContext.
Web Service Server In the web service, another handler retrieves the header block containing the correlation id and inserts it into the MessageContext of the received request.
The service may then retrieve the correlation id and set set it in the response.
Again, the handler copies the information from the MessageContext of the outgoing response to the appropriate header block.
Perhaps there are steps in the above that you do not need. Such steps can, of course, be removed.
Further inspiration can be found in, for instance, an implementation of WS-ReliableMessaging.
The steps described above is similar to the use case of JMS correlation id in the context of JMS Message.
(JMS correlation id for Request/Reply model where it involves 2 parties: Client/Consumer and Server/Provider.)
Can you re-clarify your question? Does your process involve only the server side? or client side or both end?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Jax WS - correlate request and response in a soap handler