RESTful web services

REST stands for Representational State Transfer. RESTful web services are considered a performance-efficient alternative to the SOAP web services. REST is an architectural style, not a protocol. Refer to the following diagram:

The characteristics of RESTful web services are as follows:

  • Performance: RESTful web services give better performance efficiency compared to SOAP web services as they don't have strict specifications, unlike SOAP. RESTful web services consume less network bandwidth and resource allocation for information exchange.
  • Language and platform independence: RESTful web services can be developed using diverse programming languages and can be deployed on any platform. They also allow seamless integration.
  • Support for versatile data formats: A RESTful web service allows multiple data formats for information exchange, including simple text, HTML, XML, and JSON.

While both SOAP and RESTful support efficient web service development, let's check out the difference between these two technologies in the following table:

JAX-WS and JAX-RS are the two main APIs defined by Java to develop applications based on SOAP and RESTful web service:

  • JAX-WS: This is the API provided by Java for developing SOAP web services. RPC style and Document style are the two different styles of writing SOAP web services using the JAX-WS API. While RPC-style web services use the method name and parameters to generate an XML structure, the Document style sends SOAP message as a single document.
  • JAX-RS: This is the API provided by Java for developing RESTful web services. Jersey and RESTEasy are the two prominent implementations of the JAX-RS API.

Take a look at the following diagram:

Now let's review how we can write a simple application for each of the aforementioned styles of web service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset