REST

From AutomationWiki
Jump to: navigation, search

Introduction[edit]

Representational state transfer (REST) Protocol is a simple HTTP-based protocol which was introduced in 2000 in the doctoral dissertation of Roy Fielding ( one among the chief authors of the Hypertext Transfer Protocol (HTTP) specification). REST is basically a collection of network architecture principles that describe how resources are defined and addressed.This software architecture is designed for distributed hypermedia systems like the World Wide Web. Systems which follow Fielding's REST principles are popularly known as RESTful.

Supported Client types[edit]

REST supports the following client types:

  • Web forms— They use conventional HTML forms to POST a message to a destination (queue or topic) or to GET a message from a destination.
  • Ajax clients— Ajax is an Asynchronous JavaScript And Xml (Ajax) library that enables us to communicate with a REST endpoint using JavaScript in a DHTML Web page.

Benefits[edit]

A RESTful implementation enables a user to bookmark specific queries or requests and permits those to be conveyed to others across e-mail, instant messages, or to be inserted into wikis, etc. Thus this "representation" of a path or entry point into an application state becomes highly portable.

Other major benefits of REST Protocol includes:

  • Improved response time and reduced server load due to its support for the caching of representations.
  • Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session
  • Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource
  • Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP
  • Equivalent functionality when compared to alternative approaches to communication
  • Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations
  • Better long-term compatibility and evolvability characteristics than RPC. This is due to the capability of document types such as HTML to evolve without breaking backwards or forwards compatibility and the ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types.

REST Interaction[edit]

A REST interaction generally includes following elements:

  • Operation— It belongs to a restricted, well-known set of operations—for example, in the HTTP protocol, the main operations are GET, POST, PUT, and DELETE. The operations are all known in advance hence no need arises to define interfaces for a RESTful protocol. In this regard, REST architecture is advantageous as compared to RPC architectures.

  • URI— It identifies the resource that the operation acts on. For example, a HTTP GET operation acts on the URI by fetching data from the resource identified by the URI.

  • Data (Optional)— It is required for operations that send data to the remote resource.


REST Protocol Servlets[edit]

The REST protocol is implemented by the following servlets running in a Web container:

  • message servlet— It supports the sending and consuming of messages.
  • queueBrowse servlet—It enables us to monitor the contents and view the current status of a particular queue. It is an effective and simple management tool.

RESTful Example[edit]

The World Wide Web is a major example of RESTful design and conforms to REST principles to a large extent. The Web consists of the Hypertext Transfer Protocol (HTTP), content types including the Hypertext Markup Language (HTML), and other Internet technologies such as the Domain Name System (DNS).

  • HTML can include JavaScript and applets to support code on demand, and has implicit support for hyperlinks.
  • HTTP has a uniform interface for accessing resources, which consists of URIs, methods, status codes, headers, and content distinguished by MIME type.

References[edit]

Fuse Source

Wikipedia