214
Developing Client Applications to Use a Web Service
The J2ME environment differs somewhat. Applications in J2ME environ
ments can use only stubs to access Web services, and stubs are portable for J2ME
devices. The JAX RPC profile for J2ME environments does not support dynamic
proxies and DII.
Although at this time stubs are not portable across J2EE implementations, the
next version of JAX RPC is expected to address this portability issue.
E
Using stubs, especially in a Java environment, is often the easiest because the
developer can work with generated class files representing the service method
call parameters and return values. However, the greater dependencies between
the client and the Web service may lead to problems if the service interface
changes frequently. This mode also requires that stub classes be generated be
fore compiling the application.
5.3.1.2
Using Dynamic Proxy Communication
The dynamic proxies are similar in many ways to the stubs previously described.
However, unlike stubs, the client developer needs only the client side interface that
matches the service endpoint interface. That is, clients using dynamic proxies
program to an interface that ensures the client application is portable across other
JAX RPC runtime implementations. Developers using dynamic proxies must
create Java classes to serve as JAX RPC value types these classes have an
empty constructor and set methods for each field, similar to JavaBeans classes.
The dynamic proxy is based on the service endpoint interface, its WSDL doc
ument, and a JAX RPC mapping file (similar to the stubs model). (See Figure
5.6.) Client applications can access the Web service ports using the
javax.xml.rpc.Service
method
getPort
.
Client
Service Endpoint Interface
WSDL
JAX RPC
(client side representation)
Mappings
JAX RPC Runtime
Web Service
Figure 5.6
Accessing a Service Using a Dynamic Proxy
New Page 1