JAX-RPC and J2EE 1.4 Application Clients
So far, you have seen two different ways for a
client to get a reference to the
Service object that it needs before it can invoke
the methods of a web service:
Direct instantiation of the
Serviceimplementation class. This is the technique used in Chapter 2. Although this works, it requires the application to know the name of the generatedServiceclass, which makes it dependent on a particular JAX-RPC implementation.Using a
ServiceFactoryto create aServiceobject, as shown earlier in this chapter. While this frees your code from dependency on the JAX-RPC implementation, the object you get back implements only theServiceinterface, not the actual interface defined by the web service (such asBookService). Therefore, it doesn’t have methods such asgetBookQueryPort( )that directly return references to the service endpoint interface.
If you are writing a J2SE application client, these are the only
choices available to you. However, J2EE 1.4 allows container-resident
clients to retrieve references to Service objects
defined in their JNDI environment. Furthermore, these
Service objects can be instances of generated
classes such as BookService. By using this
facility, you can write code that is vendor-independent (in the sense
that it does not rely on the actual name of the generated
Service class), while still having the convenience
of using methods such as getBookQueryPort( ). This section shows how to make use of this feature by demonstrating ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access