JAX-WS client programming model
JAX-WS client programming supports synchronous and asynchronous invocation of JAX-WS web services using either...
Dispatch client Dynamic client programming model. Use to work at the XML message level, to work without any generated artifacts at the JAX-WS level. Dynamic Proxy client Static client programming model. Use to invoke a web service based on a service endpoint interface.
Dispatch client
Although not generally necessary, you may want to work at the XML message level. Support for invoking services at the XML message level is provided by the Dispatch client API, javax.xml.ws.Dispatch. To write a Dispatch client, have expertise with...
- Dispatch client APIs
- supported object types
- message representations for the WSDL file
The Dispatch client can send data in either MESSAGE or PAYLOAD mode.
With javax.xml.ws.Service.Mode.MESSAGE mode, the Dispatch client provides the entire SOAP envelope including the <soap:Envelope>, <soap:Header>, and <soap:Body> elements.
Weith javax.xml.ws.Service.Mode.PAYLOAD mode, the Dispatch client provides the contents of the <soap:Body>, and JAX-WS includes the payload in a <soap:Envelope> element.
The Dispatch client API requires application clients to construct messages or payloads as XML which requires knowledge of the message or message payload. The Dispatch client supports the following types of objects:
- javax.xml.transform.Source
Use Source objects to enable clients to use XML APIs directly. We can use Source objects with SOAP or HTTP bindings.
- JAXB objects
Use JAXB objects so that clients can use JAXB objects that are generated from an XML schema to create and manipulate XML with JAX-WS applications. JAXB objects can only be used with SOAP or HTTP bindings.
- javax.xml.soap.SOAPMessage
Use SOAPMessage objects so that clients can work with SOAP messages. We can only use SOAPMessage objects with SOAP bindings.
- javax.activation.DataSource
Use DataSource objects so that clients can work with MIME messages. Use DataSource only with HTTP bindings.
For example, if the input parameter type is javax.xml.transform.Source, the call to the Dispatch client API is similar to the following code example:
Dispatch<Source> dispatch = create a Dispatch<Source>
Source request = create a Source object Source response = dispatch.invoke(request);
The Dispatch parameter value determines the return type of the invoke() method.
The Dispatch client is invoked in one of three ways:
- Synchronous invocation for requests and responses using the invoke method
- Asynchronous invocation for requests and responses using the invokeAsync method with a callback or polling object
- One-way invocation using the invokeOneWay methods
Refer to Chapter 4, section 3 of the JAX-WS specification for more information on using a Dispatch client.
Dynamic Proxy client
The static client programming model for JAX-WS is the called the Dynamic Proxy client.
The Dynamic Proxy client invokes a web service based on a Service Endpoint Interface (SEI) dynamically generated at run time from a WSDL file
The Dynamic Proxy instances extend the java.lang.reflect.Proxy class, and leverage the Dynamic Proxy function in the base JRE 6. The client application can provide an interface used to create the proxy instance, while the runtime is responsible for dynamically creating a Java object representing the SEI.
The Dynamic Proxy client is invoked in one of three ways:
- Synchronous invocation for requests and responses using the invoke method
- Asynchronous invocation for requests and responses using the invokeAsync method with a callback or polling object
- One-way invocation using the invokeOneWay methods
Refer to Chapter 4 of the JAX-WS specification for more information on using Dynamic Proxy clients.
Implement static JAX-WS web services clients Develop a JAX-WS client from a WSDL file Invoking JAX-WS web services asynchronously Web services specifications and APIs
JAX-WS API documentation
JAX-WS API User's Guide documentation