REST Architecture
REST Architecture
REST stands for RE presentational State Transfer. REST is web standards based architecture and uses
HTTP Protocol. It revolves around resource where every component is a resource and a resource is
accessed by a common interface using HTTP standard methods. REST was first introduced by Roy
Fielding in 2000.
In REST architecture, a REST Server simply provides access to resources and REST client accesses and
modifies the resources. Here each resource is identified by URIs/ global IDs. REST uses various
representation to represent a resource like text, JSON, XML. JSON is the most popular one.
HTTP methods
Following four HTTP methods are commonly used in REST based architecture.
Why Restful
RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make
queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete)
operations.
1. Heterogeneous languages and environments – This is one of the fundamental reasons which is
the same as we have seen for SOAP as well.
2. The event of Devices – Nowadays, everything needs to work on Mobile devices, whether it be the
mobile device, the notebooks, or even car systems.
3. Finally is the event of the Cloud – Everything is moving to the cloud. Applications are slowly
moving to cloud-based systems such as in Azure or Amazon. Azure and Amazon provide a lot of API’s
based on the Restful architecture. Hence, applications now need to be developed in such a way that
they are made compatible with the Cloud.
1. RESTFul Client-Server
This is the most fundamental requirement of a REST based architecture. It means that the server will
have a RESTful web service which would provide the required functionality to the client. The client
send’s a request to the web service on the server. The server would either reject the request or
comply and provide an adequate response to the client.
2. Stateless
The concept of stateless means that it’s up to the client to ensure that all the required information is
provided to the server. This is required so that server can process the response appropriately. The
server should not maintain any sort of information between requests from the client. It’s a very
simple independent question-answer sequence. The client asks a question, the server answers it
appropriately. The client will ask another question. The server will not remember the previous
question-answer scenario and will need to answer the new question independently.
3. Cache
The Cache concept is to help with the problem of stateless which was described in the last point.
Since each server client request is independent in nature, sometimes the client might ask the server
for the same request again. This is even though it had already asked for it in the past. This request
will go to the server, and the server will give a response. This increases the traffic across the
network. The cache is a concept implemented on the client to store requests which have already
been sent to the server. So if the same request is given by the client, instead of going to the server, it
would go to the cache and get the required information. This saves the amount of to and fro
network traffic from the client to the server.
4. Layered System
The concept of a layered system is that any additional layer such as a middleware layer can be
inserted between the client and the actual server hosting the RESTFul web service (The middleware
layer is where all the business logic is created. This can be an extra service created with which the
client could interact with before it makes a call to the web service.). But the introduction of this layer
needs to be transparent so that it does not disturb the interaction between the client and the server.
5. Interface/Uniform Contract
This is the underlying technique of how RESTful web services should work. RESTful basically works on
the HTTP web layer and uses the below key verbs to work with resources on the server