The web service a remote method invocation on an object over the network. In this tutorial, we go brief about REST web services. REST Representational State Transfer web services are built to work best on top of the internet and are designed to use the stateless communication protocol,i.e HTTP. Applications built on RESTful web services are simple, fast, and lightweight unlike that of SOAP web services.
We can see a simple Architecture in the below diagram. In the diagram, the rest client sends requests to the server typically one of the CRUD operations. The server responds with the response to the client after processing the request.
Resources are manipulated using fixed CRUD operations which maps to HTTP GET, POST, PUT, and DELETE.
CREATE : POST creates a new resource
READ :GET retrieves the current state of a resource in some representation.
UPDATE : PUT transfers to new state onto the resource.
DELETE: resource can be deleted by using DELETE.Client/Server
The above uniform interface separates rest clients from servers. Clients are not concerned with implementation details about services. Servers are not concerned with the user interface or user state of the client. Servers and clients are not tightly coupled either of them can be replaced or altered.
Hypermedia as the Engine of Application State (HATEOAS)
Rest clients deliver state via request body, query-string parameters, request headers, and the requested URI. Rest services deliver the state to clients via response body, response codes, response Headers known as hypermedia. Links are contained in the response body (or headers) to supply the URI for retrieval of the object or related objects.
Every interaction with a resource is stateless like HTTP; that is, request messages are self-contained. State-fullness is achieved through hyperlinks, such as URI rewriting, cookies. The state can be embedded in response body to point to valid future states of the interaction.
Rest clients can cache responses of web services. Server-side rest service response must, therefore, implicitly or explicitly, define themselves as cacheable or not through Header, to prevent rest clients reusing stale or inappropriate data in response to further requests.
WildFly is formerly known as the JBoss application server, now developed by Red Hat. WildFly is written in Java and implements the Java Platform, J2EE specification. It runs on multiple platforms. WildFly is free and open-source software, GNU Lesser General Public License (LGPL), version. More information at https://www.wildfly.org/
RESTEasy provides a Java API for building RESTful Web Services over HTTP. RESTEasy can run in any Servlet container, but tighter integration with the JBoss Application Server.RESTEasy libraries are bundled in the application server.
Mostly JSON, protobuf, and XML are used in Rest Web services as content-types. Many prefer protobufs for high-performance web services. Google protocol buffers serialization formats are much less when compared to XML. UI services or AJAX-style web services prefer JSON. When compared to the cost in many cases wide range rest web services offer support to all the types.