Restful Key Elements
Restful Key Elements
Restful Methods
The below diagram shows mostly all the verbs
(POST, GET, PUT, and DELETE) and an
example of what they would mean.
Let's assume that we have a RESTful web
service is defined at the
location. http://demo.guru99.com/employee
. When the client makes any request to this
web service, it can specify any of the normal
HTTP verbs of GET, POST, DELETE and
PUT. Below is what would happen If the
respective verbs were sent by the client.
1. POST – This would be used to create a
new employee using the RESTful web
service
2. GET - This would be used to get a list
of all employee using the RESTful web
service
3. PUT - This would be used to update all
employee using the RESTful web service
4. DELETE - This would be used to delete
all employee using the RESTful web
service
Let's take a look from a perspective of just a
single record. Let's say there was an
employee record with the employee number of
1.
The following actions would have their
respective meanings.
1. POST – This would not be applicable
since we are fetching data of employee 1
which is already created.
2. GET - This would be used to get the
details of the employee with Employee no
as 1 using the RESTful web service
3. PUT - This would be used to update
the details of the employee with Employee
no as 1 using the RESTful web service
4. DELETE - This is used to delete the
details of the employee with Employee no
as 1
Why Restful
Restful mostly came into popularity due to the
following reasons:
Heterogeneous languages and
environments – This is one of the
fundamental reasons which is the same as
we It enables web applications that are
built on various programming languages to
communicate with each other
With the help of Restful services, these
web applications can reside on different
environments, some could be on Windows,
and others could be on Linux.
But in the end, no matter what the environment
is, the end result should always be the same
that they should be able to talk to each other.
Restful web services offer this flexibility to
applications built on various programming
languages and platforms to talk to each other.
The below picture gives an example of a web
application which has a requirement to talk to
other applications such Facebook, Twitter, and
Google.
Now if a client application had to work with
sites such as Facebook, Twitter, etc. they
would probably have to know what is the
language Facebook, Google and Twitter are
built on, and also on what platform they are
built on.
Based on this, we can write the interfacing
code for our web application, but this could
prove to be a nightmare.
Facebook, Twitter, and Google expose their
functionality in the form of Restful web
services. This allows any client application to
call these web services via REST.
.
2. 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. So since
all Cloud-based architectures work on the
REST principle, it makes more sense for
web services to be programmed on the
REST based architecture to make the best
use of Cloud-based services.