Web Service Interaction Patterns….
There are two kinds of web service interaction patterns that are there- Synchronous and Asynchronous.
Synchronous operations expect to process an input and return an output or a fault response to the invoker within the same connection. Although this type of interaction is easy to implement, it has certain limitations.
- Synchronous operations must be able to produce a response quickly enough, before the connection between the invoker and the service times out. The specific timeout duration depends on the transport protocol and network configuration and thus is hard to predict, but usually is not expected to last longer than 30 seconds.
- The invoker of a synchronous operation waits in a blocked state for the service to return a response.
Asynchronous operations contain only input elements. No specific response is expected by the invoker except transport protocol confirmation that the request has been delivered to the target service. The service invoker is therefore unaware of the results of the request processing by the service. However, it is possible that the invoker can also present a callback capability. This would allow another asynchronous call to be made in a reverse direction. Such a callback may be used to indicate the result of the processing of the initial call that the service has received. This approach is much more flexible than synchronous interactions, because it is not time constrained.
- In asynchronous interactions each call is processed in its own connection, which passes data only in one direction.
- The invoker of an asynchronous operation does not need to wait for any specific response and therefore is not blocked.
The WS-Addressing standard is used to implement two-way asynchronous interactions. In such interactions the initial request contains a pair of WS-Addressing SOAP headers.
- A callback address header indicates the location where the callback should be directed.
- A correlation value, which is an identity of the initial request that is simply copied to any ongoing callback requests. This helps to identify the initial call which this callback needs to be associated.
Any REST or SOAP service may receive a request and generate a response or fault, which is the essence of synchronous interaction pattern. However, unlike SOAP, REST is not capable of true asynchronous communications, because REST is essentially inseparable from the HTTP transport, which is inherently synchronous.