Home Interview Questions and Answers RESTFUL Web Services Interview Questions and Answers Part-2

restful-web-services11.What are the core components of a HTTP Request?
A HTTP Request has five major parts −

Verb − Indicate HTTP methods such as GET, POST, DELETE, PUT etc.

URI − Uniform Resource Identifier (URI) to identify the resource on server.

HTTP Version − Indicate HTTP version, for example HTTP v1.1 .

Request Header − Contains metadata for the HTTP Request message as key-value pairs. For example, client ( or browser) type, format supported by client, format of message body, cache settings etc.

Request Body − Message content or Resource representation.

12.What are the core components of a HTTP response?
A HTTP Response has four major parts −

Status/Response Code − Indicate Server status for the requested resource. For example 404 means resource not found and 200 means response is ok.

HTTP Version − Indicate HTTP version, for example HTTP v1.1 .

Response Header − Contains metadata for the HTTP Response message as key-value pairs. For example, content length, content type, response date, server type etc.

Response Body − Response message content or Resource representation.

13.What is addressing in RESTful webservices?
Addressing refers to locating a resource or multiple resources lying on the server. It is analogous to locate a postal address of a person.

14.What is URI?
URI stands for Uniform Resource Identifier. Each resource in REST architecture is identified by its URI.

15.What is purpose of a URI in REST based webservices?
Purpose of an URI is to locate a resource(s) on the server hosting the web service.

16.What is format of a URI in REST architecture?
A URI is of following format −

<protocol>://<service-name>/<ResourceType>/<ResourceID>

17.What is the purpose of HTTP Verb in REST based webservices?
VERB identifies the operation to be performed on the resource.

18.What are the best practices to create a standard URI for a web service?
Following are important points to be considered while designing a URI −

Use Plural Noun − Use plural noun to define resources. For example, we’ve used users to identify users as a resource.

Avoid using spaces − Use underscore(_) or hyphen(-) when using a long resource name, for example, use authorized_users instead of authorized%20users.

Use lowercase letters − Although URI is case-insensitive, it is good practice to keep url in lower case letters only.

Maintain Backward Compatibility − As Web Service is a public service, a URI once made public should always be available. In case, URI gets updated, redirect the older URI to new URI using HTTP Status code, 300.

Use HTTP Verb − Always use HTTP Verb like GET, PUT, and DELETE to do the operations on the resource. It is not good to use operations names in URI.

19.What is statelessness in RESTful Webservices?
As per REST architecture, a RESTful web service should not keep a client state on server. This restriction is called statelessness. It is responsibility of the client to pass its context to server and then server can store this context to process client’s further request. For example, session maintained by server is identified by session identifier passed by the client.

20.What are the advantages of statelessness in RESTful Webservices?
Following are the benefits of statelessness in RESTful web services −

Web services can treat each method request independently.

Web services need not to maintain client’s previous interactions. It simplifies application design.

As HTTP is itself a statelessness protocol, RESTful Web services work seamlessly with HTTP protocol.

You may also like

Leave a Comment