Ans: Web services based on REST Architecture are known as RESTful web services. These web services use HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation such as JSON and set of HTTP Methods.
Ans: Though both RESTful Web Services and SOAP web service can operate cross platform they are architecturally different to each other, here is some of differences between REST and SOAP:
1. REST is more simple and easy to use than SOAP
2. REST uses HTTP protocol for producing or consuming web services while SOAP uses XML.
3. REST is lightweight as compared to SOAP and preferred choice in mobile devices and PDA's.
4. REST supports different format like text, JSON and XML while SOAP only support XML.
5. REST web services call can be cached to improve performance.
Ans: it represent a "resource" in REST architecture. on RESTLET API it has life cycle methods like init(), handle() and release() and contains a Context, Request and Response corresponding to specific target resource. This is now deprecated over ServerResource class and you should use that. see Restlet documentation for more details.
Ans: Some important features of Restful web services are:
Resource identification through URI:Resources are identified by their URIs (typically links on internet). So, a client can directly access a RESTful Web Services using the URIs of the resources (same as you put a website address in the browser’s address bar and get some representation as response).
Uniform interface: Resources are manipulated using a fixed set of four create, read, update, delete operations: PUT, GET, POST, and DELETE.
Client-Server: A clear separation concerns is the reason behind this constraint. Separating concerns between the Client and Server helps improve portability in the Client and Scalability of the server components.
Stateless: each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server.
Cache: to improve network efficiency responses must be capable of being labeled as cacheable or non-cacheable.
Named resources – the system is comprised of resources which are named using a URL.
Interconnected resource representations – the representations of the resources are interconnected using URLs, thereby enabling a client to progress from one state to another.
Layered components – intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients and resources to support performance, security, etc.
Self-descriptive messages: Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others
Ans: RESTful web services use HTTP protocol methods for the operations they perform.
Some important Methods are:
GET : It defines a reading access of the resource without side-effects.This operation is idempotent i.e.they can be applied multiple times without changing the result
PUT : It is generally used for updating resource. It must also be idempotent.
DELETE : It removes the resources. The operations are idempotent i.e. they can get repeated without leading to different results.
POST : It is used for creating a new resource. It is not idempotent.
Ans: You can use AJAX(Asynchronous JavaScript with XAML) and Direct Web Removing to consume web serives in web application. Both Eclipse and NetBeans also supported development of RESTFul services.
Ans: Idempotent means result of multiple successful request will not change state of resource after initial application
For example : Delete is idempotent method because when you first time use delete, it will delete the resource (initial application) but after that, all other request will have no result because resource is already deleted. Get, put and delete are HTTP Idempotent methods.
Ans:
POST :It is used for creating a new resource. It is not idempotent.
PUT : It is generally used for updating resource. It is idempotent.
Idempotent means result of multiple successful request will not change state of resource after initial application
Ans: 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.
Ans: 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.
Ans: Following is the disadvantage of statelessness in RESTful web services ? Web services need to get extra information in each request and then interpret to get the client's state in case client interactions are to be taken care of.
Ans: Always keep static contents like images, css, JavaScript cacheable, with expiration date of 2 to 3 days. Never keep expiry date too high. Dynamic contents should be cached for few hours only.
Ans: In order to customize error you need to extend StatusService and implement getRepresentation(Status, Request, Response) method with your custom code now assign instance of your CustomStatusService to appropriate "statusService property".
Ans: Since a new Resource instance is created for every incoming Request there is no need to make it thread-safe or add synchronization. multiple client can safely access RestFull resources concurrently.
That’s all on REST interview questions , I will add couple of more REST Interview questions whenever I got them from my friend circle.
Ans: Java API for RESTful Web Services (JAX-RS), is a set if APIs to developer REST service. JAX-RS is part of the Java EE6, and make developers to develop REST web application easily.
Ans: There are multiple Rest framework that can be used to create Restful web services such as
Ans: Addressing refers to locating a resource or multiple resources lying on the server. It is analogous to locate a postal address of a person.
Ans: The five important constraints for RESTful Web Service are
Ans: GET operations are read only and are safe.
Related Interview Questions...
Web API Interview Questions and Answers
ASP.Net Web API Essentials using C# Interview Questions
Weblogic Interview Questions and Answers
Web Design Interview Questions and Answers