RESTful Web services in cloud computing

RESTful Web services in cloud computing

Write short notes on RESTful Web services.

A major inspiration for RESTful Web services has been REST. This is clearly evident from the name itself. REST stands for “Representational State Transfer” and is primarily a style of software architecture for distributed hypermedia systems like the World Wide Web. Conforming to the REST constraints is termed as being RESTful. The Web is comprised of resources. A resource is any item of interest. Clients may access these resources through URLs (Uniform Resource Locators). Then a representation of these resources is returned. This representation places the client’s application in a state. REST is an architectural style and not standard, but uses several standards like HTTP (Hypertext Transfer Protocol), URL, XML, MIME (Multipurpose Internet Mail Extensions), etc. In fact, HTTP forms the very basis of REST as most of the resource handling in REST is mapped to the traditional HTTP methods like GET, POST, DELETE, etc. The latest generation of Web services has been influenced by REST to a very large extent. RESTful Web services are gaining a lot of momentum in the industry, especially with Internet companies. By using HTTP methods like PUT, GET, and DELETE alongside POST, these are often better integrated with HTTP and Web browsers than SOAP-based services. They do not require XML messages or WSDL service- API definitions. All of Yahoo’s Web services use REST, including Flickr. del.ico.us, etc.

Explain the architecture of RESTful Web services.

The Web application which follows the REST architecture is called a RESTful Web service. The architecture of RESTful Web services is shown in Fig. 1.14. REST (Representational state transfer) as the name implies, it has to do with the client and server relationship and how state is stored. REST architecture is based on the client/server architecture style. Thus, the requests and responses are built based on the transferring process of the resources. All resources are identified by a unique uniform resource identifier (URI), which typically represents a document that captures the state of the resource. Generally, the REST-style architecture is much lighter compared to SOAP. It does not require formats like headers to be included in the message like it is required in SOAP architecture. On the other hand, it parses JSON a human-readable language designed to allow data exchange and make it easier to parse and use by the computer. It is estimated to be at around one hundred times faster than XML. A simple JSON document is given below –

{
"firstname": "Usman",
"lastneme": "Saket"
}

There are several principles that designing a RESTful Web service requires. Addressability is a REST principle where the datasets are modeled to operate as URI-marked resources. Statelessness is another principle that the designer of a REST service will have to follow. This means that every transaction must be independent and must not be related to any previous transaction, as all the data required to perform and process the request are contained on that request, thus, the server will not have to maintain client session data. A uniform interface requires that an interface is uniform and standard used to access the resources, i.e. using a fixed set of HTTP methods. If the service designer holds to these principles, then it is almost guaranteed that the REST application will be simple and lightweight.

RESTful Web services use GET, PUT, POST, and DELETE HTTP methods to retrieve, create, update, and delete resources.

REST is becoming the go-to for system interaction which includes the usage of RESTful Web services mostly the way cloud providers expose their services. In the present day, we can easily conclude that most of the new projects are based on RESTful architecture in order to create and provide professional services. Large IT companies like Facebook, Google, and Twitter use REST these days.

Explain HTTP methods for RESTful Web services.

The four main HTTP methods that can be mapped to CRUD (create, read, update, and delete) operations are as follows –

(i) GET-

This method is used to retrieve the requested information from the server and is identified by the Request-URL. If the Requesting-URL refers to a data-processing process, then the data is returned by the requesting entity as the response, unless that text happens to be the output of the process. Use GET requests to retrieve resource representation/information only – and not to modify it in any way. It is said to be a safe method because it does not cause any changes to the resources stored.

For example – HTTP GET http://www.sirfpadhai.in/cloud-computing/

(ii) PUT-

PUT APIs are primarily used to update an existing resource (if the resource does not exist, then API may decide to create a new resource or not). If a new resource has been created by the PUT API, the origin server MUST inform the user agent via the HTTP response code 201 (created) response, and if an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes should be sent to indicate successful completion of the request.

For example – HTTP PUT http://www.sirfpadhai.in/cloud-computing/

(iii) POST-

Use POST APIs to create new resources i.e., the data is strictly created in the server. Talking strictly in terms of REST; POST methods are used to create a new resource into the collection of resources. Ideally, if a resource has been created on the origin server, the response SHOULD be HTTP response code 201 (Created) and contain an entity that describes the status of the request and refers to the new resource, and a location header.

For example – HTTP POST-http://www.sirfpadhai.in/cloud-computing/

(iv) DELETE –

DELETE APIs are utilized to DELETE assets. DELETE activities are idempotent. On the off chance that you DELETE an asset, it is expelled from the assortment of assets. Over and again calling DELETE API on that asset will not change the result – nevertheless, calling DELETE on an asset a subsequent time will restore a 404 (NOT FOUND) since it was at that point evacuated.

For example – HTTP DELETE http://www.sirfpadhai.in/cloud-computing/

Describe key elements of RESTful Web services.

The key elements of a RESTful implementation are as follows-

(i) Resources –

The first key element is the resource. Suppose a server containing the data of several employees and the URL of the Web application is http://www.sirfpadhai.in/. So in order to access an employee record resource via REST, one can use the command http://www.sirfpadhai.in/cloud-computing/ – this command displays the data of the Shivani 101 that is stored in the Web server and fetches the data from the server in different formats such as XML or JSON.

(ii) Request Verbs –

The request verbs describe what needs to be done with the data that is obtained from the server. The browser uses a GET request to instruct the system to get or fetch the data from the server. There are different other request verbs that can be used other than GET they are GET, PUT, POST, and DELETE. So in the example http://www.sirfpadhai.in/cloud-computing/, the browser is actually using a GET verb because it wants to get the details of the employee record.

(iii) Request Headers –

Headers are the different additional information that is being sent along with the data these headers also contain the different formats in which the data needs to be fetched. The headers also consist of the different authorization and authentication methods used.

(iv) Request Body –

Data is posted with the request. Data is normally sent in the request when a POST request is made to the REST Web service. In a POST call, the new data that is sent is added to the server if the data is not present in the server before. Therefore, the request body contains the details of where the new data needs to be added to the Web server.

(v) Response Body –

The response body is the body or the details of the response that we get from the request that is being sent. Therefore, in our example, if we were to query the Web server via http://www.sirfpadhai.in/cloud-computing/, the web server might return an XML document with all the details of the employee in the response body.

(vi) Response Status Codes –

Response status code is those codes that indicate the status of the response from the Web server. There are different codes that indicate the status of each response. For example, code 201 indicates that the new resource has been created in the Web server without error.

Give some advantages and disadvantages of RESTful API.

The advantages of RESTful API are as follows-

(i) REST uses a smaller message format and provides cost efficiency over time and better performance because of the JSON messages which makes the communication and there is no intensive processing required.

(ii) Learning curve is reduced.

(iii) It supports stateless communication.

(iv) It is simple to learn and implement.

(v) Light bandwidth since its passes message in JSON (JavaScript Object Notation) format also can use multiple other formats.

(vi) Efficiently uses HTTP verbs.

(vii) For security it uses HTTP standards.

(viii) REST can be consumed by any client.

(ix) It makes data available as a resource.

The disadvantages of RESTful API are as follows-

(i) Compared to SOAP it does not cover all varieties of Web service standards like security, transactions, etc.

(ii) REST requests (especially GET) are not suitable for large amounts of data.

(iii) REST is not reliable.

(iv) REST APIs end up depending on headers for the state (such as to route subsequent requests to the same back-end server that handled the previous update, or for authentication). The use of headers is clumsy and ties the API to HTTP as a transport.

(v) Latency is request processing times and bandwidth usage.

Previous articleWSDL in cloud computing
Next articleSoftware as a service (SaaS) in cloud computing

LEAVE A REPLY

Please enter your comment!
Please enter your name here