212
Developing Client Applications to Use a Web Service
5.3.1 Communication Modes for Accessing a Service
To best determine the communication mode for your client application, you need to
know the answers to the following two questions. Is the Web service's full WSDL
document known? Is the endpoint address for the Web service known?
As indicated, there are three principal modes for a client application's commu
nication with a Web service: stub, dynamic proxy, and dynamic invocation interface
(DII). By a communication mode, we mean the APIs for programmatically access
ing a service via the
javax.xml.rpc.Service
interface. Clients using either the
stubs or dynamic proxies to access a service require the prior definition of a
service endpoint interface. Note that when we refer to the service endpoint inter
face, which is the interface between the stub and dynamic proxy clients and the
JAX RPC API and stub, we are referring to the interface that represents the cli
ent's view of a Web service.
When using stubs, a JAX RPC runtime tool generates during development
static stub classes that enable the service and the client to communicate. The stub,
which sits between the client and the client representation of the service endpoint
interface, is responsible for converting a request from a client to a SOAP message
and sending it to the service. The stub also converts responses from the service
endpoint, which it receives as SOAP messages, to a format understandable by the
client. In a sense, a stub is a local object that acts as a proxy for the service end
point.
Dynamic proxies provides the same functionality as the stubs, but do so in a
more dynamic fashion. Stubs and dynamic proxies both provide the developer
access to the
javax.xml.rpc.Stub
interface, which represents a service endpoint.
With both models, it is easy for a developer to program against the service endpoint
interface, particularly because the JAX RPC runtime does much of the communica
tion work behind the scenes. The dynamic proxy model differs from the stub model
principally because the dynamic proxy model does not require code generation
during development.
DII is a call interface that supports a programmatic invocation of JAX RPC
requests. Using DII, a client can call a service or a remote procedure on a service
without knowing at compile time the exact service name or the procedure's signa
ture. A DII client can discover this information at runtime and can dynamically
look up the service and its remote procedures.
When using DII, clients can dynamically access a service at runtime. The
stubs rely on a tool that uses the WSDL file to create the service endpoint inter
face, plus generate stub and other necessary classes. These generated classes elim
New Page 1