In Chapter 2, you saw that in order to get a stub
web service endpoint interface, it was
first necessary to obtain a reference to a
object, using code like this:
BookService_Impl service = new BookService_Impl( ); BookQuery bookQuery = (BookQuery)service.getBookQueryPort( ); BookInfo books = bookQuery.getBookInfo( );
BookService_Impl is a class generated by
wscompile that implements the
javax.xml.rpc.Service interface. As noted in Chapter 2, there is no standard naming convention for
this generated class (although the JAX-RPC specification recommends
one); therefore, making use of the class name in this way introduces
a dependency in your code on a specific JAX-RPC implementation.
Although there is nothing that you can do about this if your client
application uses the stubs generated by wscompile,
it is possible to make your code more portable if you use
or the dynamic invocation
static stubs, or if you build a
J2EE application client instead of a
standalone J2SE client. In order to see how this can be done, it is
necessary first to look in more detail at the
Service interface and the
ServiceFactory class to which it is related.
ServiceFactory is an abstract class that can
be used to create
Service objects in a portable
manner. The public methods of
are shown in Example 6-2.
Example 6-2. The ServiceFactory class
public abstract class ServiceFactory ...