How Soap supports asynchronous call while Rest does not?

21,960

Solution 1

REST is purely an HTTP transport based call and you will receive a response say 200 OK on the other side,

SOAP uses two varieties,

  • Synchronous Messaging over HTTP
  • Asynchronous Messaging over HTTP

With synchronous messaging, the Requestor makes a request and the transport layer code blocks waiting for a response from the Provider. The Requestor receives the response on the same HTTP connection that the Requestor initially established to send the request. Synchronous exchange is usually easier to implement and requires that the Provider be able to generate a response in a short time, specifically in a time less than the HTTP timeout value(generally 120sec). [A single HTTP Connection is used that itself behaves Synchronously]

With asynchronous messaging, the Requestor is able to release transport specific resources once the request is acknowledged by the responder, knowing that a response will eventually be received. When the Provider completes the processing of the message it sends a response back to the Requestor over a new HTTP connection. [Here we utilize two HTTP Connections to implement an asynchronous messaging

  • first HTTP Connection is used that for sending the Request and receiving an acknowledgement HTTP Response 200/OK
  • second HTTP Connection is used for receiving the callback and responding HTTP Response 200/OK]

Rijoy https://soascribbles.wordpress.com/

Solution 2

SOAP defines a reply approach that allows for asynchronous computing, like a callback mechanism. You can achieve the same with REST but there is no specification for it, so you would have to build it yourself.

Here is an example using JAX-WS 2.0 demonstrating the feature.

I found useful information in Wikipedia WS-Addressing, which has a link for this W3C Specification.

In the past I also developed in SAP ESB designer which allowed for asynchronous service interface methods. Although I never used that feature, that tool was fully compliant with SOAP specification and I am pretty sure it would work just like the Java example above, since the WSDL was used to generate JAX-WS server based. If I have time next week I will use that option to so see what happens and post it here.

You should also check this answer which address pertinent aspects of this approach.

Share:
21,960
M Sach
Author by

M Sach

Updated on July 09, 2022

Comments