7.16. Web Service Clients
7.16.1. Service
Service
is an abstraction that represents a WSDL service. A WSDL service is a collection of related ports, each of which consists of a port type bound to a particular protocol and available at a particular endpoint address.
7.16.1.1. Service Usage
Most clients will start with a WSDL file, and generate some stubs using jbossws tools like wsconsume. This usually gives a mass of files, one of which is the top of the tree. This is the service implementation class.
// Generated Service Class @WebServiceClient(name="StockQuoteService", targetNamespace="http://example.com/stocks", wsdlLocation="http://example.com/stocks.wsdl") public class StockQuoteService extends javax.xml.ws.Service { public StockQuoteService() { super(new URL("http://example.com/stocks.wsdl"), new QName("http://example.com/stocks", "StockQuoteService")); } public StockQuoteService(String wsdlLocation, QName serviceName) { super(wsdlLocation, serviceName); } ... }
In the dynamic case, when nothing is generated, a web service client uses Service.create
to create Service instances, the following code illustrates this process.
URL wsdlLocation = new URL("http://example.org/my.wsdl"); QName serviceName = new QName("http://example.org/sample", "MyService"); Service service = Service.create(wsdlLocation, serviceName);
7.16.1.2. Handler Resolver
Service
instance provides access to a HandlerResolver
via a pair of getHandlerResolver
and setHandlerResolver
methods that may be used to configure a set of handlers on a per-service, per-port or per-protocol binding basis.
Service
instance is used to create a proxy or a Dispatch
instance then the handler resolver currently registered with the service is used to create the required handler chain. Subsequent changes to the handler resolver configured for a Service
instance do not affect the handlers on previously created proxies, or Dispatch
instances.
7.16.1.3. Executor
Service
instances can be configured with a java.util.concurrent.Executor
. The executor will then be used to invoke any asynchronous callbacks requested by the application. The setExecutor
and getExecutor
methods of Service
can be used to modify and retrieve the executor configured for a service.