Search This Blog

Tuesday, December 10, 2019

Web Services in Java


Web Service:
·         Web services are client and server applications that communicate over the World Wide Web’s (WWW) HyperText Transfer Protocol (HTTP).
·         As described by the World Wide Web Consortium (W3C), web services provide a standard means of interoperating between software applications running on a variety of platforms and frameworks.
·         Web services are characterized by their great interoperability and extensibility, as well as their machine-processable descriptions, thanks to the use of XML.
·         Web services can be combined in a loosely coupled way to achieve complex operations. Programs providing simple services can interact with each other to deliver sophisticated added-value services.

Loosely Coupled:

In computing and systems design a loosely coupled system is one in which each of its components has, or makes use of, little or no knowledge of the definitions of other separate components.
Subareas include the coupling of classes, interfaces, data, and services.[1] Loose coupling is the opposite of tight coupling.

Types of Web Services in Java

1.       Java API for XML Web Services (JAX-WS)
·         Big web services use XML messages that follow the Simple Object Access Protocol (SOAP) standard, an XML language defining a message architecture and message formats.
·         systems often contain a machine-readable description of the operations offered by the service, written in the Web Services Description Language (WSDL), an XML language for defining interfaces syntactically.
A SOAP-based design must include the following elements.
·         A formal contract must be established to describe the interface that the web service offers.
·         WSDL can be used to describe the details of the contract, which may include messages, operations, bindings, and the location of the web service
·         The architecture must address complex nonfunctional requirements.  Examples include transactions, security, addressing, trust, coordination, and so on.
·         The architecture needs to handle asynchronous processing and invocation.

1.       Java API for RESTful Web Services (JAX-RS).

In Java EE 6, JAX-RS provides the functionality for Representational State Transfer (RESTful) web services. 
RESTful web services, often better integrated with HTTP than SOAP-based services are, do not require XML messages or WSDL service–API definitions.
                A RESTful design may be appropriate when the following conditions are met.
·         The web services are completely stateless. A good test is to consider whether the interaction can survive a restart of the server
·         A caching infrastructure can be leveraged for performance. If the data that the web service returns is not dynamically generated and can be cached, the caching infrastructure that web servers and other intermediaries inherently provide can be leveraged to improve performance.
·         The service producer and service consumer have a mutual understanding of the context and content being passed along.
·         Bandwidth is particularly important and needs to be limited.
·         Web service delivery or aggregation into existing web sites can be enabled easily with a RESTful style
·         Developers can use such technologies as JAX-RS and Asynchronous JavaScript with XML (AJAX) and such toolkits as Direct Web Remoting (DWR) to consume the services in their web applications.