Chapter 5 Client Design
213
inate the need for the developer to use the JAX RPC APIs directly. By contrast,
the dynamic proxy and DII approaches both require the developer to use the JAX
RPC APIs.
5.3.1.1
Using Stub Communication
J2EE clients should use generated stubs to access services, especially for services
with fairly static interfaces. Stub communication easily allows Java access to a Web
service. This is the recommended approach for accessing services and their WSDL
files when they are unlikely to change over time.
Figure 5.5 shows how a client application might access a Web service using a
stub generated by a tool prior to the client's deployment and compilation. The
WSDL file for the service served as input to the tool. The client side service end
point interface, which implements the service endpoint interface on the client side
of the communication channel, provides the client view of the Web service.
The stub, which implements the client side service endpoint interface, acts as
a proxy to the Web service for the client; that is, the stub is the client's view of the
Web service. The tool that generates the stub class also generates all necessary
helper classes for accessing the service. These helper classes define the parame
ters for calls to the service and the service's return values, ensuring that the
parameters and return values are all of the proper types expected by the JAX RPC
runtime. To generate these stub and helper classes, the tool relies on the WSDL
document as well as a JAX RPC mapping file. The mapping file supplies infor
mation regarding the Java to XML bindings, such as the correct package name for
generated classes.
Client
WSDL
Tool
Service Endpoint
Stub
JAX RPC
Interface
Mappings
JAX RPC Runtime
Web Service
Figure 5.5
Stub Communication Model
New Page 1