Signup/Sign In

Types of Web Services: SOAP and REST

There are two types of web services:

  1. SOAP Web Services
  2. REST Web Services

SOAP Web Services

SOAP is an XML-based protocol. The biggest advantage of using the SOAP Web Service is its own security. SOAP stands for Simple Object Access Protocol.

SOAP provides an envelope to send a web services messages over the Internet, using the HTTP protocol. The messages are generally in XML format.

SOAP request envelope

In simple words, SOAP is a technique to send an XML request over the Internet using HTTP protocol (hitting a URL), and in return getting an XML response.

Taking a real world example, if a client wants to fetch a school's student data, by sending in the student's Roll No. in the request, he can do so using web services. But how will the client know, which URL to call and what to send in the request?

SOAP communication real life example

Well, every application serving SOAP requests, has a WSDL file. WSDL is an XML, and it stands for Web Service Description Language. WSDL describes all the methods available in the web service, along with the request and response types. It describes the contract between service and client.

SOAP was intended to be a way to do remote procedure calls to remote objects by sending XML over HTTP.

If we look at the current software industry, you will find that, SOAP is being used in the enterprise applications, generally in the legacy code. Today the world is moving fast towards the RESTful Web Services.


REST Web Services

The REST stands for Representational State Transfer. REST is not a set of standards or rules, rather it is a style of software architecture. The applications which follow this architecture are referred to as RESTful

Unlike SOAP which targets the actions, REST concerns more on the resources. REST locates the resources by using URL and it depends on the type of transport protocol(with HTTP - GET, POST, PUT, DELETE,...) for the actions to be performed on the resources. The REST service locates the resource based on the URL and performs the action based on the transport action verb. It is more of architectural style and conventions based.

For Example: in a RESTful architecture, this URL http://{serverAddress}/students/studentRollno/07 can be used to:

  • To get student information by sending a REST call of GET type, and the service will return information of student with roll no as 07
  • The same service can also be used to update the student data, by sending in the new values as Form data in a PUT request.

REST architecture example


Difference between REST and SOAP

Here are some of the basic differences between the two types of web services:

REST SOAP
REST is a style of software architecture. SOAP is a protocol or a set of standards.
REST stands for Representational State Transfer SOAP stands for Simple Object Access Protocol
REST can use SOAP because it is a concept and can use any protocol like HTTP, SOAP etc. SOAP cannot use REST because it itself is a protocol.
REST uses URI to expose business logic. But as REST works on the basis of type of HTTP request, hence same URI can work for more than a single type of operation. SOAP uses the service interface to expose business logic.
REST does not define too much standards. REST is cool! SOAP defines standards to be strictly followed.
REST inherits security measures from the underlying transport protocols. SOAP defines its own security layer.
REST accepts different data formats like, Plain Text, HTML, JSON, XML etc. SOAP only works with XML format.