Web Services: SOAP vs REST

Jalitha Dewapura
3 min readMay 15, 2021

--

Web Services

Before talk about SOAP and REST, you should understand the term of web services. Web services are any services offered through the Web-wide standardized protocols(TCP, UDP, HTTP, etc). It can be a client-server application or application component for communication.

Features of Web Service

  • XML-Based
  • Loosely Coupled
  • Coarse-Grained
  • Ability to be Synchronous or Asynchronous
  • Supports Remote Procedure Calls (RPCs)
  • Supports Document Exchange

Benefits of Web Service

  • A Standardized Protocol that can be understood by anyone
  • Exposing existing Functionality on the network
  • Ease of use
  • Communication cost is low
  • Interoperability

There are two types of web services

  • SOAP Web Services
  • RESTful Web Services

What is SOAP (Simple Object Access Protocol)

SOAP is an XML-based protocol for accessing web services over HTTP. It was created long before the REST was introduced. The fundamental goal of developing SOAP was to ensure the communication between various applications written on different platforms and computer languages.

Every programming language can understand the XML markup language. Hence, XML was used as the underlying medium for data exchange.

SOAP provides an envelope to send web service messages over the Internet.

SOAP envelope consists of two components

  • SOAP Head — optional
  • SOAP Body — mandatory

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

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.

Advantages of SOAP

  • Both platform and language independent
  • More secure than REST
  • Built-in error handling

Disadvantages of SOAP

  • Slower due to XML format
  • Only support XML
  • Tight coupling between client and server

When considering the current software industry, SOAP is being used in enterprise applications, generally in the legacy code. Today the world is moving fast towards RESTful Web Services.

What is REST (Representational State Transfer)

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.

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 an architectural style and conventions-based.

Advantages of REST

  • Low use of resources
  • More Dynamic
  • Can use with XML, JSON and, YAML
  • More performance and scalability than SOAP

Disadvantages of REST

  • Less secure
  • Lose the ability to maintain state

I hope you learn something new about web services. If I missed any points, let me know your suggestion in the comment section.

Reference

[1] https://www.javatpoint.com/what-is-web-service

[2] https://smartbear.com/blog/soap-vs-rest-whats-the-difference/

--

--

Jalitha Dewapura

BSc. (Hons) in Engineering, Software Engineer at Virtusa