Awarious OfficePortal - HRMS Application

Difference between REST Services and Restless SOAP Services Example

0 votes
asked Jul 21, 2013 in Software Practices by Sruthi
recategorized Jul 21, 2013 by administrator

Could please help me understand what is REST services? Why do we call the Service as REST and How it is different from regular SOAP services? What would be the benefit if I use REST Service? When should I use one over the other?


2 Answers

+1 vote
answered Jun 5, 2014 by Patrik
selected Jun 5, 2014 by administrator
Best answer

REST: Representational State Transfer

What is REST:
REST services are an architectural style similar to SOAP services, but uses HTTP protocol and HTTP methods (GET, PUT, POST and DELETE) to do communication between client and server application. SOAP services, in fact we should not even compare REST with SOAP because SOAP is really not architecture style, it is a message exchange style between client and server. SOAP services are RPC (Remote Procedural Call) architecture style which will be using metadata (i.e Service Contracts) to communicate between client and server.

Key difference between RESTful service and RESTless (SOAP) Service:
REST services are called as REST services because, the services are really working with Resources instead of operations. Any communication between client and services are using URI (Unified Resource Identifier) over HTTP protocol using HTTP method. The URI is really to representation of the Resources (like Customer, Account, Location etc). Also, in RESTful service, once you identified the Resource, you will be working with a uniform interface, because it uses HTTP methods (GET, PUT, POST and DELETE) to work with the resource. So, client does not need to know what the exact operation name defined in the service contract to call that method. GET method is used whenever we need to get the representation of an existing resource. POST is used to add new resource into the system. PUT is to modify the existing resource and DELETE is to remove the resource from the system.

In SOAP Service (We will use WCF as example for RPC) whenever you design, you may need to identify the Service and the Operations (like GetCustomer, SaveCustomer(), UpdateCustomer(), DeleteCustomer()) on that Service. Also, each service will work with different contracts (i.e Custom Interface), because the operations are named by the developers. So anyone can name the operations differently. Because of this, the consumer / client needs to know the service contract completely if they need to work with that service. Also, they need to know which operation is doing what kind of activity.

How to call REST Vs RPC Services (SOAP Based Message):
Since RESTful services are based on HTTP protocol, it is very light weight and it is available everywhere and no additional framework needed to call the service. URI is similar to URL of a webpage. So, when you want to browse a web page you may be using URL. In the browser world, everything is resource and each resource will have unique identifier. Same as that, REST Services are URI based. So, if you want to call a webservice, you can use a URI and call the service using HTTP request.

In SOAP Services, the service contract has to be shared to the client. Then client will be using that contract to create proxy and calls the service. Because of that, the client needs to know about the service and the operations to work with that. Not only that, but when the communication happens, the client and server both need some kind of tool /component/framework which knows what SOAP messages are? How to read information from that message? How to serialize it? Etc.

How service methods are identified in REST vs RPC services:
In case of SOAP services, when you call a service operation from client, the dispatcher in the webservice side will first De-serialize the SOAP message, and then it identifies the action from the message to be performed. Actions are mapped with the service methods. So, once the action is identified, the dispatcher will call the operation.

But when you design a RESTful service, you will not be identifying the service and operations. Instead you will be identifying the resources. Once the resources are identified, the HTTP method (GET, PUT, POST and DELETE) will identify the method to be called. When client calls the service method in RESTful service using the URI, dispatcher will identify the Resource, and then based on the HTTP method; it will identify the service method. So, each method in the Webservice will be mapped with one of the HTTP Verb. Once the dispatcher identifies the HTTP Verb, it will call the respective method in the service.

commented Feb 9, 2016 by Sunil
Very good explanation of the concepts.
commented Apr 2, 2016 by anonymous

Cool explanation, thx! There is a misspell: Put is used for creating new resource and Post to modify existing.

commented May 8, 2016 by Vaibhav

Very good explanation. Love to read such articles.

commented Jun 20, 2016 by anonymous
Great comprehensive explanation.
commented Jul 26, 2016 by jenith leon
Very good explanation...Thank you..!!!
commented Aug 26, 2016 by anonymous

Excellent Explanation. Very simple and yet informative

commented Sep 21, 2016 by Nidhi Gupta
Perfect explanation. Exactly what I was looking for. :)
commented Dec 13, 2016 by anonymous
Cool Explanation.Put is used for updation of the existing details and post is used for the creation of the new resource.
commented Mar 15, 2018 by anonymous
Very clear and nice explanation
0 votes
answered Nov 11, 2016 by TAMILSELVI THANGARAJ

Awesome Explanation.. Really helpful

commented Mar 22, 2018 by anonymous
Superb. Thumbs up

Your answer


Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2019