Sunday, April 2, 2017


Posted earlier long back in 2014 … Why REST -
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.
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.
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 preferred than REST
REST more preferred than 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. 
  • Stateless
    • Each client request to the server requires that its state be fully represented.
    • The server must be able to completely understand the client request without using any server context or server session state.
    • It follows that all state must be kept on the client. 
  • Cacheable
    • 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. 

Hope this helps.

Arun Manglick

No comments:

Post a Comment