Monday, August 8, 2016

Integration Shift - SOAP Vs REST

I can start by saying SOAP is an older sibling of REST, however both provides a way of accessing Internet / http.
SOAP provides more of a standard way of access through WSDL whereas REST gives a simplistic approach by solely leveraging http standard.
SOAP is more of a messaging protocol that supports jms etc along with http whereas REST is http based and is more of an architectural style which forces implementation to have certain design constraints.
REST is more light weight as SOAP uses xml along with defined structure of soap envelope whereas Rest uses simple url along with json which is easily parseable as javascript object.
As a developer, I normally don’t get to decide when to choose soap vs rest, however I have my perspective.
Typically with the mobile apps, mostly apis are rest based as bandwidth is limited on the go. Mobile interfaces are mostly stateless.
Platform APIs almost always support Rest and typically provide language specific client side libraries to invoke the apis.
As SOAP has been the standard for implementing webservices for a decade, there has been extensive support for SOAP and still for asynchronous use cases, wsdl based contracts, soap may be better suited.
Any deviation / opinion as well scenario based use case feedback  / discussion is appreciated.
Example of SOAP vs REST request for retrieving user
<?xml version="1.0"?><soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:body pb="http://www.acme.com/phonebook"><pb:GetUserDetails><pb:UserID>12345</pb:UserID></pb:GetUserDetails></soap:Body></soap:Envelope>
http://www.acme.com/phonebook/UserDetails/12345
As can been seen, in order to retrieve the details of the user, a xml request with <envelope> & <body> has to be created whereas using REST, URL is all we need.
In the next post, I will write about REST based architectural style and its constraints.

No comments:

Post a Comment