Saturday 25 August, 2007

When to use REST and when to use SOAP

There are so many pages and blogs on REST vs SOAP that a person like me who wants to know which one to use where, simply gets confused. These blogs and pages talk more about pros and cons of REST and/or SOAP, while I believe every such thing has a place in a particular scenario. In other words, REST will be applicable (please note I am not saying better!) in some cases, while SOAP will be applicable in some other cases. Fortunately, I found this article by Sameer Tyagi, which gives good advice on when to use REST and when to use SOAP. Let me quickly outline my understanding of Sameer's article in this blog.

A RESTful design may be appropriate when
  • Completely stateless web services are needed.
  • A caching infrastructure can be leveraged.
  • The requirement is for point-to-point integration. This means both service consumer and provider have mutual understanding of the context and content being passed.
  • Limited bandwidth exists between service consumer and provider; e.g. having mobile device as a consumer.
  • Front-end technologies such as AJAX and DWR are being used.
A SOAP-based design may be appropriate when
  • A formal contract is needed for a service (to be provided as WSDL).
  • Complex non-functional (aka QoS) requirements are present and need to be handled in a standardized way.
  • Requirements for asynchronous service invocation are present.
Now this kind of information comes handy when a solution is to be proposed for a particular case.

3 comments:

Ujjwal Trivedi said...

Thanks Shrikant, I ve been trying to understand REST as a RoR newbie. Your blog and referred one (Sameer's) certainly gives a headstart beacause i have found other resources to be exceptionally terse when it comes to REST. May be my understanding isnt That RESTful yet. It would be great if you can add more to this article. in your lucid way of course. :-)

Vintage Freak said...

Appreciate the synopsis Shrikant. Was looking for something like this. I just had a question. Do you know of a good reference regarding the appropriateness of the "payload format" in REST requests and responses. XML is the obvious choice, but I was looking for other options, particularly JSON.

Best.

Manish Jain said...

Exactly what I was looking for..Thanks for taking time to blog it.