REST is an architecture, SOAP is a protocol.
Per Wikipedia, Representational state transfer (REST) is the software architectural style of the World Wide Web. REST’s coordinated set of constraints, applied to the design of components in a distributed hypermedia system, can lead to a higher-performing and more maintainable software architecture. To the extent that systems conform to the constraints of REST they can be called RESTful. RESTful systems typically, but not always, communicate over Hypertext Transfer Protocol (HTTP) with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) that web browsers use to retrieve web pages and to send data to remote servers.
And SOAP, originally an acronym for Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of web services in computer networks. It uses XML Information Set for its message format, and relies on application layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.
So What is difference between the two?
|Business logic||Uses URI to expose business logic||Uses services interfaces|
|Cacheable||REST reads can be cached built in to the architecture||RPC communications are often not cached as part of the HTTP stack|
|Complexity||Simple HTTP requests that return results in JSON||SOAP is a more complex API that communicates by passing XML around|
|Data Format||HTML, JSon, XML, Plain text, etc.||XML|
|Messaging Support||Client handles communication failure by re-trying.||SOAP has successful/retry logic built in (WS-ReliableMessaging)|
|Mostly used||Public API's||Enterprises|
|Overhead||Less bandwidth and resources.||More bandwidth and resources. SOAP Envelope to wrap each calls.|
|Protocol||HTTP (Typically)||HTTP, FTP, SMTP, etc.|
|Security||SSL||SOAP supports SSL (just like REST) it also supports WS-Security|
|Share||You can easily share the URL around.||Unable to share the URI. SOAP describes a series of methods, along with their parameters and return values.|
|Transactions Support||Yes, but it isn’t as comprehensive and isn’t ACID compliant||Full Supports (WS-AtomicTransaction)|
- REST is good for exposing public API’s over the internet to handle CRUD operations.
- REST is focused on accessing named resources through a single consistent interface.
- REST is implementation-agnostic and much more transparent, and this makes it great for public APIs.
- REST version are simpler, clearer, run faster, and uses less bandwidth.
- SOAP brings focuses on operations and exposing pieces of application logic (not data) as services.
- SOAP is focused on accessing named operations, each implement some business logic through different interfaces.
- SOAP has very little if anything to do with the Web. REST provides true “Web services” based on URIs and HTTP.