These days I am hooked to quora.com. The quality of content it provides is awesome.
Quora marks another important point to be taken care by Internet Marketing firms and professionals that internet is overcrowded by information. The quantity doesn’t matter, quality does. Quality of content is the only thing that drives users engagement and helps to get a larger user base. And when they are engaged, they turn them into active users. Only this that matters for a business.
So, I was answering an question on quora regarding difference between REST(Representational State Transfer) and SOAP(Simple Object Access Protocol). And after 5 days, today I re-read it again and I found awesome (yes, I know I am saying I did awesome :P). I found it worth sharing here :
Backlink : LINK TO ORIGINAL POST BY PRADEEP KUMAR
In layman terms you are asking –
What’s the difference between a building plan-map and building making process.
In software terms you are asking –
What’s the difference between MVC and HTTP.
Now, let’s co-relate them:
Building plan map, MVC and REST are architectural patterns.
Building making process, HTTP and SOAP are set of rules i.e. protocols.
And now the big deals :
Building Plan map is deciding how you will place different things e.g. Bathroom, dining room, doors, bed-room etc. in a particular geographical area.
MVC is deciding how you will separate concerns regarding data, business logic and controls.
REST is deciding how you will use different HTTP verbs to perform one of CRUD operation on your data.
Building making process is following predefined steps like first create foundation then walls and in the end go for roof.
HTTP is following predefined rules like you need to send request on port 80 which will consist of two parts: HTTP headers and HTTP body.
SOAP is following predefined set of rules how and where you can place function to be called and various parameters to be passed in that function in your XML SOAP request.
When to use any and trade-offs:
To understand this, you need to understand differences between JSON and XML.(google it else answer will be too long ;))
SOAP is rigid XML structure. XML is overwhelmed by data-size.
REST can use XML or JSON. JSON is just key – value pairs.
1. when you have no other option provided by API exposer.
2. when your end user want to have only SOAP response.
3. Faster development. As tools Axis 2 and cxf exist. 🙂
Use REST(with JSON):
1. To have cleaner software architecture.
2. To save server resources (JSON is smaller to process).
3. To save network resources (JSON size is smaller than XML).
4. To save client side resources (JSON is much faster to parse).
With SOAP you are confined to XML only. With REST you have option to generate XML or JSON.