Web Services can be used within EJBs or servlets/JSPs. This integration conforms to the JSR 921(Web Service for J2EE v1.1) specification (see http://www.jcp.org/en/jsr/details?id=921).
Note | |
---|---|
While JSR 921 is in a maintenance review phase, we provide a link to the 109(v1.0) specification (http://www.jcp.org/en/jsr/details?id=109). |
An XML-based format for specifying the interface to a Web Service. The WSDL details the service's available methods and parameter types, as well as the actual SOAP endpoint for the service. In essence, WSDL is the "user's manual" for the Web Service. (See http://www.w3.org/TR/wsdl.)
An XML-based protocol for sending request and responses to and from Web Services. It consists of three parts: an envelope defining message contents and processing, encoding rules for application-defined data types, and a convention for representing remote procedure calls and responses. (See http://www.w3.org/tr/SOAP.)
The Java API for XML based RPC. RPC (Remote Procedure Call) enables a client to execute procedures on other systems. The RPC mechanism is often used in a distributed client/server model in which the server defines a service as a collection of procedures that may be called by remote clients. In the context of Web Services, RPCs are represented by the XML-based protocol SOAP when transmitted across systems.
In addition to defining the envelope structure and encoding rules, the SOAP specification defines a convention for representing remote procedure calls and responses. An XML-based RPC server application can define, describe and export a Web Service as an RPC-based service. WSDL (Web Service Description Language) specifies an XML format for describing a service as a set of endpoints operating on messages. With the JAX-RPC API, developers can implement clients and services described by WSDL. (See http://www.jcp.org/en/jsr/detail?id=101.)
Strictly speaking, a Web Service is a well-defined, modular, encapsulated function used for loosely coupled integration between applications' or systems' components. It is based on standard technologies, such as XML, SOAP, and UDDI.
Web Services are generally exposed and discovered through a standard registry service. With these standards, Web Services consumers (whether they be users or other applications) can access a broad range of information—personal financial data, news, weather, and enterprise documents—through applications that reside on servers throughout the network.
Web Services use a WSDL Definition as a contract between client and server (which are called endpoints). WSDL defines the types to serialize through the network (described with XMLSchema), the messages to send and receive (composition, parameters), the portTypes (abstract view of a Port), the bindings (concrete description of PortType: SOAP, GET, POST, ...), the services (set of Ports), and the Port (the port is associated with a unique endpoint URL that defines the location of the Web Service).
A Web Service for J2EE is a component with some methods exposed and accessible by HTTP (through servlets). Web Services can be implemented as Stateless Session Beans or as JAX-RPC classes (a simple Java class, no inheritance needed).
Figure 29-1. Web Services endpoints deployed within JOnAS (an external client code can access the endpoint via AxisServlet)
The servlet is used to respond to a client request and dispatch the call to the designated instance of servant (the SSB or JAX-RPC class exposed as Web Service). It handles the deserialization of incoming SOAP message to transform SOAP XML into a Java Object, perform the call, and serialize the call result (or the thrown exception) into SOAP XML before send the response message to the client.