Java Architecture Interview questions
REST stands for REpresentational State Transfer.
What is REST?REST is web standards based architecture and uses HTTP Protocol for data communication. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods. REST was first introduced by Roy Fielding in 2000.
In REST architecture, a REST Server simply provides access to resources and REST client accesses and presents the resources. Here each resource is identified by URIs/ global IDs. REST uses various representations to represent a resource like text, JSON and XML. Now a days JSON is the most popular format being used in web services.
Name some of the commonly used HTTP methods used in REST based architecture?Following well known HTTP methods are commonly used in REST based architecture −
- GET − Provides a read only access to a resource.
- PUT − Used to create a new resource.
- DELETE − Ued to remove a resource.
- POST − Used to update a existing resource or create a new resource.
- OPTIONS − Used to get the supported operations on a resource.
A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer.
What are RESTful webservices?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.
What is a Resource in REST?REST architecture treats every content as a resource. These resources can be text files, html pages, images, videos or dynamic business data. REST Server simply provides access to resources and REST client accesses and modifies the resources. Here each resource is identified by URIs/ global IDs.
How to represent a resource in REST?REST uses various representations to represent a resource where text, JSON, XML. XML and JSON are the most popular representations of resources.
What are the best practices to design a resource representation?Following are important points to be considered while designing a representation format of a resource in a RESTful web services −
- Understandability − Both Server and Client should be able to understand and utilize the representation format of the resource.
- Completeness − Format should be able to represent a resource completely. For example, a resource can contain another resource. Format should be able to represent simple as well as complex structures of resources.
- Linkablity − A resource can have a linkage to another resource, a format should be able to handles such situations.
RESTful web services make use of HTTP protocol as a medium of communication between client and server.
What is messaging in RESTful webservices?