Popular Posts

Friday, January 27, 2017

REST & SOAP Web Service/API Difference / Comparison

Though difference between REST and SOAP web service is very old question, a updated detailed answer is always needed. Below notes help to understand which is better, and useful in different scenarios for design / development:

SOAP (Simple Object Access Protocol)
• To make applications communicate to each other (sending and receiving messages) over internet, over HTTP (it's supported by all browsers and servers) - SOAP was created.
• SOAP provides a standard way to communicate between applications running on different OS, with different technologies and languages.

• SOAP is an Application Communication PROTOCOL, which runs over a Transport Protocol
• SOAP is independent of transport protocol (could be HTTP, SMTP, FTP, TCP, UDP, even email)
• On HTTP (default SOAP transport protocol), only the POST verb is used
• SOAP is platform / language independent
• SOAP supports XML messages only
• Contract (WSDL) based system, Tightly coupled
• Action /Service oriented system (leads to Service Oriented Architecture)

• CXF, Metro, Kenai (RI), Axis, Spring WS

REST (Representational State Transfer)
• SOAP and REST can't be compared directly, since the first is a protocol and the second is an architectural style.
• Like SOAP, REST is also transport protocol independent. REST application can use any protocol for which there is an standardized URI scheme.
• REST makes full use of the specific features of that protocol (verbs GET, POST, PUT, DELETE, caching, stateless, predefined error codes – all are HTTP properties).

• Supports variety of format - JSON/XML/Plain HTML etc
• Loosely coupled, no contract needed
• Everything is just URL based
• REST is very lightweight (no heavy XML header/body needed)
• REST is data / resource oriented (leads to Resource Oriented Architecture)
• For a truly RESTFUL api, all RESTFUL Constraints (Client-Server, Stateless, Cache, Interface / Uniform Contract, Layered System, Code-On-Demand) should be followed

• CXF, Jersey (RI), RESTEasy, Spring RESTful

Designing REST API :
http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/
https://stormpath.com/blog/fundamentals-rest-api-design
https://www.thoughtworks.com/insights/blog/rest-api-design-resource-modeling

No comments: