File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Jax WS - correlate request and response in a soap handler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Jax WS - correlate request and response in a soap handler" Watch "Jax WS - correlate request and response in a soap handler" New topic
Author

Jax WS - correlate request and response in a soap handler

Cristian Popovici
Ranch Hand

Joined: Apr 13, 2007
Posts: 32
Hi,

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).

Regards,
Cristi.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
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.
Best wishes!

My free books and tutorials: http://www.slideshare.net/krizsan
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
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.)


OP,

Can you re-clarify your question? Does your process involve only the server side? or client side or both end?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jax WS - correlate request and response in a soap handler