REST vs SOAP

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?

 RESTSOAP
Business logicUses URI to expose business logicUses services interfaces
CacheableREST reads can be cached built in to the architectureRPC communications are often not cached as part of the HTTP stack
ComplexitySimple HTTP requests that return results in JSONSOAP is a more complex API that communicates by passing XML around
Data FormatHTML, JSon, XML, Plain text, etc.XML
Messaging SupportClient handles communication failure by re-trying.SOAP has successful/retry logic built in (WS-ReliableMessaging)
Mostly usedPublic API'sEnterprises
OperationsGET,POST,PUT,DELETEPOST
OverheadLess bandwidth and resources.More bandwidth and resources. SOAP Envelope to wrap each calls.
ProtocolHTTP (Typically)HTTP, FTP, SMTP, etc.
SecuritySSLSOAP supports SSL (just like REST) it also supports WS-Security
ShareYou can easily share the URL around.Unable to share the URI. SOAP describes a series of methods, along with their parameters and return values.
SpecificationLooseRigid
Transactions SupportYes, but it isn’t as comprehensive and isn’t ACID compliantFull Supports (WS-AtomicTransaction)
WADL/WSDLWADLWSDL

 

  • 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.

References: