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.