Previous section   Next section
Service javax.xml.rpc

JAX-RPC 1.0; JWSDP 1.0, J2EE 1.4
public interface Service {
// Property Accessor Methods (by property name)
    public abstract javax.xml.rpc.handler.HandlerRegistry getHandlerRegistry(  );
    public abstract Iterator getPorts(  ) throws ServiceException;
    public abstract javax.xml.namespace.QName getServiceName(  ); 
    public abstract javax.xml.rpc.encoding.TypeMappingRegistry getTypeMappingRegistry(  ); 
    public abstract java.net.URL getWSDLDocumentLocation(  ); 
// Public Instance Methods
    public abstract Call createCall(  ) throws ServiceException; 
    public abstract Call createCall(javax.xml.namespace.QName portName) 
       throws ServiceException; 
    public abstract Call createCall(javax.xml.namespace.QName portName, 
        javax.xml.namespace.QName operationName) throws ServiceException;
    public abstract Call createCall(javax.xml.namespace.QName portName, 
    String operationName) throws ServiceException; 
    public abstract Call[ ] getCalls(javax.xml.namespace.QName portName) 
       throws ServiceException; 
    public abstract java.rmi.Remote getPort(Class serviceEndpointInterface) 
         throws ServiceException; 
    public abstract java.rmi.Remote getPort(javax.xml.namespace.QName portName, 
         Class serviceEndpointInterface) throws ServiceException;
}

Service is the core interface of the JAX-RPC client-side API, representing a service element in a WSDL definition of a web service. There are several ways to obtain a Service object, which are discussed in the following list.

The getWSDLDcoumentLocation( ) method returns the URL for the WSDL document from which the Service is generated, or null if it is not created from a WSDL document. The getServiceName( ) method returns the fully qualified name of the service in the form of a javax.xml.namespace.QName object.

A web service is composed of one or more ports, each of which is an access point for an instance of the service with an associated address. A single web service might be accessible at more than one address (and therefore have multiple ports) if it supports more than one transport protocol, or perhaps for load-balancing or mirroring reasons. You can use the getPorts( ) method to get an Iterator over all of the ports of the service. In the case of an unconfigured Service object, this Iterator does not contain any elements.

To get an object that can be used to invoke the methods of a specific service endpoint interface, use one of the getPort( ) methods and cast it to the service endpoint interface type. These methods throw a ServiceException if invoked on an unconfigured Service object. The two-argument getPort( ) method returns an object that can be used to invoke the methods of a port given the fully qualified name of the port from the WSDL definition, and a Class object that represents the Java interface created from the port definition. The returned value can be cast to the given class type. The one-argument variant supplies only the Java interface, and does not specify the qualified name of the port. Use of this method is not recommended in circumstances in which it can be avoided because it requires a search of the WSDL definition to locate a port whose operations match the methods defined by the Java interface. This requires not only a comparison of method and operation names, but also their argument types. The getPort( ) methods may return an instance of a pregenerated stub class or a dynamic proxy, which is a class generated on-the-fly that implements the methods of the service endpoint interface accessible through the named port. Dynamic proxies are actually implemented using the DII, as described in the reference section for Call earlier in this chapter.

The createCall( ) methods return a Call object that can be used to construct a DII call to one of the methods provided by the service. The two-argument variants create a Call object that is fully configured to invoke a specific method, whereas the one-argument variant requires you to additionally specify the operation name using the methods of the Call interface. The zero-argument variant of this method requires you to specify both the port name and the operation name before attempting to make a call. The getCalls( ) method returns an array of Call objects, each of which is fully configured to invoke one method of the service endpoint interface. Each time this method is called, it generates and returns a new set of Call objects and is therefore a relatively expensive operation. A ServiceException is thrown if this method is called on an unconfigured Service object.

The getTypeMappingRegistry( ) method returns a reference to the type mapping information relating to the service. This information, which determines how Java data types are mapped to and from their corresponding XML representation in SOAP messages, is created dynamically from the WSDL definition of the service or the equivalent Java interface. Some implementations may also allow you to add additional mappings, as described in Chapter 6 of this book. The getHandlerRegistry( ) method returns a HandlerRegistry object that contains the configuration of SOAP handlers that will appear in the processing pipeline for messages sent to the service. SOAP handlers can modify or extract information from a SOAP message before it is sent or after it is received. Refer to Chapter 6 or Chapter 15 for further information.

Returned By

ServiceFactory.createService( )


  Previous section   Next section