WAS v8.5 > Reference > Developer detailed usage informationWSIFOperation - Asynchronous interactions reference
The WSIF supports asynchronous operation. In this mode of operation, the client puts the request message as part of one transaction, and carries on with the thread of execution. The response message is then handled by a different thread, with a separate transaction.
Asynchronous operation is supported by the WSIF providers for SOAP over JMS and native JMS.
The WSIFPort class uses the supportsAsync method to test whether asynchronous operation is supported.
An asynchronous operation is initiated with the WSIFOperation interface executeRequestResponseAsync method. This method lets a Remote Procedure Call (RPC) method be invoked asynchronously. The method returns before the operation is completed, and the thread of execution continues.
The response to the asynchronous request is processed by the WSIFOperation interface fireAsyncResponse or processAsyncResponse methods.
To initiate the request, there are two forms of the executeRequestResponseAsync method:
public WSIFCorrelationId executeRequestResponseAsync (WSIFMessage input, WSIFResponseHandler handler)public WSIFCorrelationId executeRequestResponseAsync (WSIFMessage input)
- executeRequestResponseAsync(WSIFMessage input, WSIFResponseHandler handler)
This method takes an input message and a WSIFResponseHandler handler. The handler is invoked on another thread when the operation completes. When using this method, the client listener calls the fireAsyncResponse method, which then calls the WSIFResponseHandler interface executeAsyncResponse method.
For more information about the WSIFResponseHandler interface, see the generated API documentation supplied with WSIF (see the Apache WSIF website).
- executeRequestResponseAsync(WSIFMessage input)
- This method only takes an input message, and does not use a response handler. The client listener processes the response by calling the WSIFOperation interface processAsyncResponse method. This process updates the WSIFMessage output and fault messages with the result of the request.
WSIF supports correlation between the asynchronous request and response. When the request is sent, the WSIFOperation object is serialized into the WSIFCorrelationService object. The executeRequestResponseAsync methods return a WSIFCorrelationId object that identifies the serialized WSIFOperation object. The client listener can use this to match a response to a particular request.
The correlation service is located with the WSIFCorrelationServiceLocator class getCorrelationService() method in the org.apache.wsif.utils package.
In a managed container a default correlation service is defined in the default JNDI namespace using the name: java:comp/wsif/WSIFCorrelationService. If this correlation service is not available, WSIF uses the WSIFDefaultCorrelationService.
For more information about the WSIFCorrelationService interface, see the generated API documentation supplied with WSIF.
This is the correlator ID:
public interface WSIFCorrelator extends Serializable { public String getCorrelationId(); }The client must implement its own response message listener or message data base so that it can recognize the arrival of response messages. This client implementation manages the correlation of the response message to the request and call of one of the asynchronous response processing methods. As an example of the requirement for a client listener, the following code fragment shows what can be in the onMessage method of a JMS listener:
public void onMessage(Message msg) { WSIFCorrelationService cs = WSIFCorrelationServiceLocator.getCorrelationService(); WSIFCorrelationId cid = new JmsCorrelationId( msg.getJMSCorrelationID() ); WSIFOperation op = cs.get( cid ); op.fireAsyncResponse( msg );}
Related
Invoking a WSDL-based web service through the WSIF API
Reference:
WSIFOperation - Context
WSIFOperation - Synchronous and asynchronous timeouts reference
Linking a WSIF service to a JMS-provided service
Related information: