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
class. This is the technique used in Chapter 2.
Although this works, it requires the application to know the name of
Service class, which makes it
dependent on a particular JAX-RPC implementation.
ServiceFactory to create a
Service object, 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 the
Service interface, not the actual interface
defined by the web service (such as
Therefore, it doesn’t have methods such as
getBookQueryPort( ) 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
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 ...