Jul 29, 2016

Difference between SOAP and REST

This is not a tutorial of SOAP or REST web services. It aims at listing out differences between two, which is one of most common interview question. 

Web Services are method of communication between 2 applications over the network. There are two types of web services:
·         SOAP
·         REST

Below are some key differences between the two types of web services:
  • SOAP stands for Simple Object Access Protocol and REST stands for REpresentational State Transfer.
  • SOAP is a protocol while REST is architectural style, on which RESTful web services are build.
  • SOAP uses XML messages for communication while REST is based on HTTP protocol.
  • SOAP response is always in XML format whereas REST can return response in various formats like XML, JSON, HTML.
  • RESTful web service request is much faster than processing a SOAP message because you need to do less parsing.
  • SOAP messages consume more bandwidth than RESTful messages as SOAP has an additional header for every message while RESTful services utilize HTTP header.
  • SOAP web services are language, platform and transport independent whereas RESTful Web services are heavily dependent upon HTTP.
  • RESTful web services utilize URL to identify the desired resources to be accessed while SOAP uses XML messages to identify the desired web procedure or resource to be invoked.
  • SOAP defines its own security whereas RESTful web services inherits security measures from the underlying transport.
  • RESTful services provide a good caching infrastructure over HTTP while SOAP totally ignores web caching mechanism.
  • SOAP uses JAX-WS java API while RESTful web services uses JAX-RS java API.
  • SOAP define standards to be strictly followed in Web Services Description Language (WSDL) that contains and describes the common set of rules to define the messages, bindings, operations and location of the Web service.  RESTful web services has no such standard rules so the service provider and service consumer need to have a common understanding of the context as well as the content being passed along.
  • REST-based implementation is simple compared to SOAP.


In a nutshell, when you're publishing a complex application program interface (API) to the outside world, SOAP will be more useful. But if you need a lightweight API with faster results and simple transactions (i.e., CRUD operations), go with REST.

Hopefully it helps! You can connect with us at +Java Territory to stay updated with latest articles.

0 comments:

Post a Comment