Simple Object Access Protocol (SOAP): Differences Between REST and SOAP

Lecture



SOAP (from the English Simple Object Access Protocol) — a protocol for exchanging structured messages in a distributed computing environment. Initially SOAP was intended mainly for implementing remote procedure calls (RPC). Now the protocol is used for exchanging arbitrary XML-format messages, not just for procedure calls. The official specification of the latest version, 1.2, of the protocol does not spell out what SOAP stands for at all .

SOAP is an extension of the XML-RPC protocol.

SOAP can be used with any application-layer protocol: SMTP, FTP, HTTP, HTTPS, etc. However, its interaction with each of these protocols has its own peculiarities that must be defined separately. Most often SOAP is used on top of HTTP.

SOAP is one of the standards that web service technologies are based on.

Protocol structure

Simple Object Access Protocol (SOAP): Differences Between REST and SOAP
Structure of a SOAP message

A SOAP message looks like this:

  • Envelope — the root element that defines the message and the namespace used in the document.
  • Header — contains message attributes, for example: security information or network routing information.
  • Body — contains the message that applications exchange.
  • Fault — an optional element that provides information about errors that occurred while processing messages.

Example

Example of a SOAP request to an online store server:

 Simple Object Access Protocol (SOAP): Differences Between REST and SOAP  

Example of a response:

 Simple Object Access Protocol (SOAP): Differences Between REST and SOAP

Drawbacks

  • Using SOAP to transmit messages increases their size and reduces processing speed. In systems where speed matters, sending XML documents directly over HTTP is more common, with request parameters passed as ordinary HTTP parameters.

Comparing REST and SOAP

Actually, comparing them is a bit like comparing apples to oranges, since SOAP is an XML-based protocol format, whereas REST is an architectural approach.

REST and SOAP are not really comparable. REST is an architectural style. SOAP is a message exchange format. Let's compare popular implementations of the REST and SOAP styles.

Example of a RESTful implementation: JSON over HTTP

Example of a SOAP implementation: XML over SOAP over HTTP

At a high level, SOAP constrains the structure of your messages, whereas REST is an architectural approach focused on using HTTP as the transport protocol.

The specifics of SOAP lie in the data exchange format. With SOAP it's always SOAP-XML, which is XML that includes:
— Envelope – the root element that defines the message and the namespace used in the document,
— Header – contains message attributes, for example: security information or network routing information,
— Body – contains the message that applications exchange,
— Fault – an optional element that provides information about errors that occurred while processing messages. Both the request and the response must conform to the SOAP structure.

The specifics of REST are in using HTTP as the transport protocol. It implies making the best use of the features HTTP provides — request methods, request headers, responses, response headers, etc.

Message exchange format

In SOAP you use the SOAP XML format for requests and responses.

REST has no such fixed format. You can exchange messages based on XML, JSON, or any other convenient format. JSON is the most popular of the formats used.

Service definitions

SOAP uses WSDL (Web Services Description Language) — an XML-based language for describing web services and accessing them.

REST has no standard service definition language. Although WADL was one of the first proposed standards, it isn't very popular. Using Swagger or OpenAPI is more common.

Transport

SOAP does not impose any restrictions on the type of transport protocol. You can use either the HTTP web protocol or MQ.

REST implies making the best use of the HTTP transport protocol

Ease of implementation

RESTful web services are generally much easier to implement than SOAP-based web services.

REST typically uses JSON, which is easier to parse and process. In addition, REST does not require a service definition to be present in order to expose a web service.

With SOAP, however, you need to define your service using WSDL, and there is significant overhead when processing and parsing SOAP-XML messages.

There is also an author's video on this topic.

Summary

In this article we took a detailed look at the differences between REST and SOAP.

See also

  • [[b5768]] Rest API
  • WSDL
  • WDDX
  • AMQP

See also

created: 2020-12-08
updated: 2026-03-10
156



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)