Web Services and REST (Representational State Transfer)

What is a web service ?

This is a system designed to support interoperability among systems that are connected over the network.

Web services is service oriented architecture (SOA).

Somebody provides a service, somebody else consumes the service provided by the other person. So this is standardized way of integrating web based applications using open standards. So that clients can communicate with servers, there is a standardized way of exchanging information between the two sites.

There are two common approaches that people take for implementing web services.

  1. One approach, called a Simple object access protocol, or SOAP, uses something called the Web Services Description Language (WSDL).

    SOAP uses XML as the presentation approach.

  2. Other approach REST, or representational state transfer.

    This uses web standards.

    The data exchange can happen either using XML or JSON.

    REST is simpler compared to SOAP and WSDL.

SOAP and WSDL have a lot more features that are more suitable for distributive operation across the Internet. But for typical web applications communicating with the server, REST seems to work just fine.

What is REST ?

It is a style of software architecture for distributed hypermedia systems, like the World Wide Web.

So, REST is a more general concept than what we use in the World Wide Web.

REST is a collection of network architecture principles, which specify how you can identify the sources, how you can access them, how you can address your sources, and how you can perform operations on those resources.

Four basic design principles for REST-
1) Use HTTP methods explicitly
2) Be stateless
3) Expose directory structure like URI’s.
4) Transfer using XML or JSON or both

The motivation for REST was to capture the characteristics of the Web that made the Web successful-
1) URI (Uniform Resource Identifier) addressable resources.2) HTTP Protocol
3) Make request – receive response – display response

Exploits the use of HTTP Protocol beyong HTTP GET and POST-
1) uses HTTP PUT and DELETE.
2) Preserve Idempotence.

REST Grammar:
1) Nouns:
These are the resources represented by URI’s.
2) Verbs:
Verbs are the HTTP request GET (read), POST (create), PUT (update) and DELETE (delete).
3) Representation: It is the format in which data is represented, it is either JSON or XML.

REST is stateless on server side, this helps in scalability of server.
Client side should track its state using cookies, client-side database etc. Client side should include sufficient information for server to serve the request.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s