Labels

Sunday, April 2, 2017

REST vs SOAP

Posted earlier long back in 2014 … Why REST - http://arun-ts.blogspot.com/2014/08/what-why-rest_6.html
Here again an attempt to find buzz question REST vs SOAP .. J 
Before this, understand REST underlying concepts: 

REST Concepts are referred to as Resources.
  • Resources are manipulated by Components.
  • Components, request and manipulate Resources via a Standard Uniform Interface.
  • In case of HTTP, this interface consists of standard HTTP ops e.g. GET, PUT, POST, DELETE.
 Differences:
REST vs SOAP is not the right question to ask. SOAP is a protocol. REST is an architectural style.

SOAP stands for Simple Object Access Protocol
REST stands for Representational State Transfer.

SOAP is a protocol.
REST is an architectural style. 
REST has defined guidelines for creating services which are scalable. 
REST used with HTTP protocol uses its verbs GET, PUT, POST and DELETE.

SOAP transport protocol is HTTP only
REST is protocol independent. It's not coupled to HTTP. Pretty much like you can follow an ftp link on a website, a REST application can use any protocol for which there is an standardized URI scheme.

However REST is optimized for the web, due to its support for JSON, hence incredible popularity of REST over HTTP!
SOAP uses services interfaces to expose the business logic.


SOAP is focused on accessing named operations, each implement some business logic through different interfaces.
REST uses Consistent/Standard URI to expose business logic. In case of HTTP, this interface consists of standard HTTP ops e.g. GET, PUT, POST, DELETE

REST is focused on accessing named resources through a Standard Uniform/Consistent Resource Interface.

SOAP defines standards to be strictly followed.

REST does not define too much standards like SOAP
SOAP defines its own security. e.g. WS-Security, WS-AtomicTransaction, WS-ReliableMessaging etd.

RESTful web services inherits security measures from the underlying transport.
SOAP requires more bandwidth and resource than REST (Due XML Based)
REST requires less bandwidth and resource than SOAP
(Due JSON Based)
SOAP permits XML data format only
REST permits different data format such as Plain text, HTML, XML, JSON etc
SOAP based reads cannot be cached.
REST has better performance and scalability
REST reads can be cached.
SOAP can't use REST because SOAP is a protocol.

REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.

SOAP is less inter-operable way to implement client-server, as many environments still don't have SOAP toolkits. And some that do have toolkits are based on older standards that can't always communicate with toolkits that implement newer standards.
REST is more inter-operable than SOAP. REST only requires an HTTP library to be available for most operations, and it is Certainly More Inter-operable Than Any RPC Technology (including SOAP).
  
Fundamental REST Principles:

  • Client-Server Communication
    • Client-server architectures have a very distinct separation of concerns.
    • All applications built in the RESTful style must also be client-server in principle. 
  • Inter-operable:
    • Many people advertize SOAP as being the most inter-operable way to implement client-server programs. But some languages and environments still don't have SOAP toolkits. And some that do have toolkits are based on older standards that can't always communicate with toolkits that implement newer standards.
    • REST only requires an HTTP library to be available for most operations, and it is Certainly More Inter-operable Than Any RPC Technology (including SOAP).
  • Stateless
    • REST encourages each resource to contain all of the states necessary to process a particular client request.
    • Thus  server mcompletely understand the client request without using any server context or server session state.
  • Cacheable
    • Few Approaches to make Cacheable: Link1, Link2
      • Entity Tags (ETags) that don’t rely on shared agreement on time
      • The Last-Modified HTTP header, which is date-time-centric
      • The Vary Header
    • When RESTful endpoints are asked for data using HTTP, the HTTP verb used is GET.
    • Resources returned in response to a GET request can be cached in many different ways.
    • e.g. Cache constraints may be used, thus enabling response data to be marked as cacheable or not-cacheable. Any data marked as cacheable may be reused as the response to the same subsequent request. 
  • Uniform Interface
    • All components must interact through a single uniform interface.
    • Because all component interaction occurs via this interface, interaction with different services is very simple.
    • The interface is the same! This also means that implementation changes can be made in isolation.
    • Such changes, will not affect fundamental component interaction because the uniform interface is always unchanged. 

Reference: http://stackoverflow.com/questions/19884295/soap-vs-rest-differences

Hope this helps.

Arun Manglick

No comments:

Post a Comment