What Is REST
What Is REST
By Binu Chawla
OVERVIEW
What is REST ?
Resources and Representations
6 Constraints of REST architecture
Advantages of REST
Each resource is identified by a unique identifier or URIs/ global IDs. Just like
web pages have urls, rest apis have uri and addresses too.
Sample: <protocol>:/<service-endpoint>/<service-name>/<method-
name>/<resourceId>
http://162.144.126.209:8080/mortgage-v1.3.2/SSN/registerSsn.do
So in RESTful Web Services, Server is viewed as a set of resources and can
beaccessed usingUniform Resource Identifiers (URIs).
How does the server identify the request?
How does the client know which data format is being sent?
Metadata which is a part of the request and response header.
The http request header contains information like which http method
(GET,PUT,POST,DELETE), is used, the uri, the http version and query string parameters.
The http response header contains status code, content type which can be
application/json, or text/plain.
Every request and response contains meta data about the format of content being sent.
Different representation of same record or underlying data is being sent to different
client.
When you send any request or you get any response, you are actually sending
representations. REST uses various representations to represent a resource like html,
text, JSON, XML, pdf, and jpeg. So, we are transferring the representational state and
goes the name REST.
1. Uniform Interface
2. Stateless
3. Cacheable
4. Client-Server
5. Layered System
6. Code on Demand (optional)
UNIFORM INTERFACES
Client can directly access a resource using its URI which is a direct advantage of
RESTful web service over SOAP web service, where client needs WSDL and XML message
transfer in form of envelope, headers etc.
For REST no middleware is required, only HTTP support is needed
REST is much more light weight and can be implemented using almost any tool leading
to lower bandwidth and shorter learning curve
Development with REST is easier and quicker than SOAP. Because, of this most of the
vendors are adopting RESTful Web Services e.g Flickr, Google etc. That is why REST is
often used in mobile applications,social networkingWeb sites,mashuptools,
andautomated business processes.
SOAP or REST
In general, when we are publishing an api to the outside world which is either
complex or likely to change, then SOAP is best. Other than that REST is a good
choice.
If the operation needs a guaranteed level of security and reliability, then
SOAP offers additional standards to ensure this type of operation.
Key to using SOAP based services is the WS - Standards. If there are a lot of
non functional requirements like security, transaction management etc. then
we can rely on the SOAP framework that provides all the standards for such
requirements.
REST is good for web services. However, SOAP is good for the enterprise
services that need high reliability, transaction mgmt. and high security.
SOAP v/s REST