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?
subject: Jax WS - correlate request and response in a soap handler