Basic Difference in SOAP and REST Web Services – Quick Tips

Author: | Posted in PHP, Quick Tips, Technology No comments


REST/SOAP – Web services terminology

Now, Most of the application follow Service Oriented Architecture(SOA) so WWW is evolving as service oriented marketplace where web-service plays a critical role in this evolution.

What is a Web service?

A web service is a way of communication between two electronic devices over the World Wide Web .

W3C defines web service as a “software system designed to support inter-operable machine-to-machine interaction over a network. It has an interface described in a machine-process-able format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.”

A more constrained architectural style for reliable Web applications known as Representation State Transfer (REST) was proposed by Roy Fielding. [2] In a REST-style architecture requests and responses are built around the transfer of representations of resources. A resource (e.g. Person) can be essentially any coherent and meaningful concept that may be addressed. A representation of a resource is typically a document (e.g. XML or JSON) that captures the current or intended state of a resource.

What is SOAP?

SOAP is a protocol specification for exchanging structured information in the implementation of Web Services. It uses XML for the message format. It is independent of the transport protocol (could be HTTP, FTP, TCP, UDP, or named pipes).

SOAP based services strictly define the format of messages passed back and forth. A SOAP message contains the data, the action to perform on it, the headers, and the error details in case of failure. Security is provided by WS-Security standards and is end-to-end. It supports identity through intermediaries, not just point to point (SSL).

SOAP provides a mechanism for services to describe themselves to clients (WSDL), and to advertise their existence (UDDI). SOAP also provides reliable messaging (WS-ReliableMessaging), that is a successful retry logic built in and provides end to end reliability through soap intermediaries.

What is REST?

Representational State Transfer (REST) is an architecture style for designing networked applications, that

Involves clients and servers sending request and responses respectively.
Request and response are built around the transfer of representations of resources.
(e.g. request JSON representation of User)
REST recognizes everything a resource (e.g. User, Lottery, etc.) and each resource implements a standard uniform interface (typically HTTP interface), resources have name and addresses (URIs), each resource has one or more representation (like JSON or XML) and resource representations move across the network usually over HTTP.

RESTful web APIs (or RESTful web service) is a web API implemented using HTTP and principles of REST. RESTful API separates user interface concerns from data storage concerns. It improves portability of interface across multiple platforms and simplifies server components by making them stateless. Each request from client contains all the state information and server does not hold client context in the session.


One of the major benefits of SOAP is that you have a WSDL service description. You can pretty much discover the service automatically and generate a use-able client proxy from that service description (generate the service calls, the necessary data types for the methods and so forth). Note that with version 2.0, WSDL supports all HTTP verbs and can be used to document RESTful services as well, but there is a less verbose alternative in WADL (Web Application Description Language) for that purpose.

With RESTful services, message security is provided by the transport protocol (HTTPS), and is point-to-point only. It doesn’t have a standard messaging system and expects clients to deal with communication failures by retrying. SOAP has successful/retry logic built in and provides end-to-end reliability even through SOAP intermediaries.

One of the major benefits of RESTful API is that it is flexible for data representation, for example you could serialize your data in either XML or JSON format. RESTful APIs are cleaner or easier to understand because they add an element of using standardised URIs and gives importance to HTTP verb used (i.e. GET, POST, PUT and DELETE).

RESTful services are also lightweight, that is they don’t have a lot of extra xml markup. To invoke RESTful API all you need is a browser or HTTP stack and pretty much every device or machine connected to a network has that.

RESTful service has good performance because they don’t have additional overhead of  parser and headers.

when it comes to SOAP vs REST, but the only performance difference I know of is that SOAP has a lot of overhead when sending/receiving packets since it’s XML based, requires a SOAP header, etc. REST uses the URL + querystring to make a request, and thus doesn’t send that many kB over the wire

Security is another key performance concern. REST applications typically use TLS or other session layer security mechanisms. TLS is much faster than using application level security mechanisms such as WS Security (WS Security also suffers from security flaws).

WS-Security adds significant overhead to SOAP processing due to the increased size of the message on the wire, XML and cryptographic processing, requiring faster CPUs and more memory and bandwidth

(Visited 85 times, 1 visits today)