REST V/S SOAP
1. SOAP(Simple Object Access Protocol) is a Protocol in which there is a communication
between the client and the server whereas REST(Representational State Transfer) is an
Architecture which uses existing protocols to communicate between the client and the server.
2. SOAP exposes behaviour which represents logic whereas REST exposes resources which
represents data .For eg:doing addition is the logic whereas Calculator is a resources which can
perform various operations.Database Table is a resource by which we can read,create,delete or
update the data.
3.For Machine to Machine interaction we use SOAP API For eg. Banking software would be
used internally within a bank only there is no public client which is using that particular services
In banking we also require a good security options. When we require an API which should be a
public facing API.For eg.Facebook API .Most of the public facing API are REST
4.SOAP can work on almost any internet protocol whereas REST works mostly on HTTP
5.SOAP permits only XML whereas REST permits not only XML but also JSON,HTML etc
6.SOAP is more secure as it uses SSL and WS Security it means that it has it’s own security
whereas REST inherit security measures from the underlying transport
7.SOAP can’t use rest because it’s a protocol whereas REST can use SOAP because it’s a
concept any can use any protocol like HTTP,SOAP etc
8.SOAP has WSDL(Web Services Description Language) definition whereas REST has no
WSDL interface definition.WSDL is a XML based Language for describing web services and
how to access them .
9.In SOAP there is a overhead to have envelope, Header and Body apart from the message
whereas in REST there are only messages. That is why SOAP is heavy weight and REST is light
weight
10.SOAP defines standards to be strictly followed whereas REST doesn’t defines to much
standards like SOAP.
From the above points it clear that REST is far better than SOAP as it’s overhead is less,follows
no or less strict standards,fast,permits different
dataformats,lightweight,maintainable,scalable,consumes less bandwidth etc.
It uses HTTP for all 4 CRUD methods-HTTP methods
Create(POST)
Read(GET)
Update(PUT)
Delete(DELETE)
These are very suitable for browser based interactions
REST reads can be cached so better performance as the request will not have to go to server in
fact it can be read from the cache without interfacing the server again. SOAP based reads cannot
be cached
In SOAP we are sending an envelope so the business logic se not very clear because it we are
sending the envelope and it is defined in the envelope only whereas in REST we can get the
business logic by getting the URI itself
Moreover it is device independent that is the client consuming REST API can be anything like
Mobile Devices,Notebooks,TV etc.
Clouds based systems such as Azure,Amazon AWS etc are build and exposing REST APIs. If
we want to use that cloud and put our applications then it’s better to have it in a REST API the
compatibility and maintainability will be far better.
Almost 70% of the public APIs are REST APIs.The Google glass API,known as “Mirror API” ,
is a pure REST API.Twitter has a REST API .Flickr and Amazon are also using REST.