REST stands for representational state transfer.It is an architectural pattern for creating client server applications.There are other client server communication methods such as SOAP based web services ,remoting and RPC.
Web Services are used for creating applications which communicate with each other over network.Untill now SOAP was mostly used for creating web services.SOAP web service uses XML based SOAP language to define the message structure.It requires a proxy to consume the SOAP web services.
RESTful web services are based on the HTTP protocol and its different methods ,which are GET,POST,PUT and DELETE.OPTIONS is used to get the operations which are available
for a resource.
Following are the main points of a RESTful web service.
- Resources are identified with a URL
- HTTP verbs are used to perform different operations on the resources
- Each interaction with REST service is stateless.
- Resources can be represented in different formats such as JSON,XML and Plain Text.
URL’s are used to represent the reources.So for example a URL for customer entities would be represented with the following URL
For performing different operations on the entity we need to just access the customers by using the different HTTP methods.Following represents the different operations on the customer entities
CustomerService/customers/1 returns customer with id 1 GET
CustomerService/customers returns all the customers GET
CustomerService/customers/2 inserts a new customer with id 2 PUT
CustomerService/customers/1 updates customer with id 1 POST
CustomerService/customers/1 deletes customer with id 1 DELETE