A web service is a service offered by an electronic device to another electronic device, communicating with each other via the World Wide Web. Wikipedia
SOAP and REST are both types of web services that are beautiful in their own way. So I am not implying one is better over the other, instead, I am trying to depict the picture.
In both of these there will be a client or consumer of the web service, the web service itself hosted on a remote server. The manner in which and the types of operations client performs with regards to this remote service can be understood by the means of differentiation below.
|Acronym||Simple Object Access Protocol||Representational State Transfer|
|Basic Idea||Is a protocol exposing operation||Is an architecture style exposing resources|
|Protocols||HTTP, SMTP, etc…||HTTP Only|
|Definition||WSDL (Web Service Description Language). It exposes the methods available to the client and the set of rules inputs and outputs the client would have to adhere to in the SOAP envelope in order to successfully consume those methods||RSDL (RESTful Service Description Language) Is an description of web applications typically rest web services|
|Verbs||Client does not adhere to the verbs concept here. In-fact the client sends out the request in a SOAP envelope as defined by the WSDL||Client can use a set of Verbs to perform task. POST – To create, GET – To Read, PUT – To Update & DELETE – To Delete|
|State||Stateful – The SOAP request is stateful, giving client the state information on the request made||Stateless – Each request from the client contains all the information necessary to service the request and the result of the request can be queried by a subsequent call|
|Bandwidth||Requires more bandwidth compared to REST||Less when compared to SOAP|
|Security||SOAP and REST both support SSL in addition to this SOAP also supports WS-Security with enterprise security features with standard data integrity and privacy features||RESTful support security from underlying transport i.e. SSL|
|Data Formats||XML only this is limiting in some situations||Plain Text, HTML, XML, JSON etc…|
|Client Debugging||Built in error handling. If request were to fail response would contain error information (provided the web service is written correctly and they are sending as much information possible) to help start debugging||Sends HTTP error codes. Not as robust as SOAP|
|Reliability||Has retry logic. Provides end to end reliability through SOAP intermediaries||Does not have the standard messaging system and leaves it to the client to deal with communication failure usually by retrying|
|Client setup||Client implementation (envelope creation etc…) required||Easier to consume compared to SOAP. Requires a simple REST URL in many cases to make a request|