REST is an architecture style that defines a set of constraints to be used for creating web services. Moreover, it is considered an alternative to SOAP & WSDL. REST architecture was developed based on the lessons learned from previous approaches to create web services while avoiding their shortcomings. REST is based on four main constraints: addressability, statelessness, self-descriptiveness, and a layered system; and has emerged as an alternative to the heavily used, but more complex web service technologies, for example SOAP and WSDL.
Why REST?
- It reduces the cost of implementation, maintenance, and support, thereby increasing IT staff productivity.
- You can reuse existing platform components and increase scalability and availability of applications.
- Addressability of resources: URI identifies every resource (property, item, data type etc.). Thereon, they can be accessed using standard HTTP methods.
- Stateless protocol: Servers and clients need to maintain no client context between requests. The HTTP protocol allows the server to handle requests in any order. This lets clients act as simple browsers.
- Self-descriptive messages: Each resource representation contains all the information necessary to understand the message. This includes the resource’s media type.
- Layered system.Resource functionality can be layered to allow delegation of processing for optimal performance.
- Code on demand: A Web Service may provide executable code along with its representation to compute or process a response.
- Cacheable: Clients can cache responses to reduce the number of requests they have to send to a Web Server.