Network Deployment (Distributed operating systems), v8.0 > Applications > Web services > Web services > JAX-WS


JAX-WS client programming model

The Java API for XML-Based Web Services (JAX-WS) web service client programming model supports both the Dispatch client API and the Dynamic Proxy client API. The Dispatch client API is a dynamic client programming model, whereas the static client programming model for JAX-WS is the Dynamic Proxy client. The Dispatch and Dynamic Proxy clients enable both synchronous and asynchronous invocation of JAX-WS web services.



Dispatch client

XML-based web services use XML messages for communications between web services and web services clients. The JAX-WS APIs provide high-level methods to simplify and hide the details of converting between Java method invocations and their associated XML messages. However, in some cases, you might desire to work at the XML message level. Support for invoking services at the XML message level is provided by the Dispatch client API. The Dispatch client API, javax.xml.ws.Dispatch, is a dynamic JAX-WS client programming interface.

To write a Dispatch client, have expertise with the Dispatch client APIs, the supported object types, and knowledge of the message representations for the associated Web Services Description Language (WSDL) file. The Dispatch client can send data in either MESSAGE or PAYLOAD mode. When using the javax.xml.ws.Service.Mode.MESSAGE mode, the Dispatch client is responsible for providing the entire SOAP envelope including the <soap:Envelope>, <soap:Header>, and <soap:Body> elements. When using the javax.xml.ws.Service.Mode.PAYLOAD mode, the Dispatch client is only responsible for providing 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 a detailed knowledge of the message or message payload. The Dispatch client supports the following types of objects:

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:

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) which must be provided. The Dynamic Proxy client is similar to the stub client in the Java API for XML-based RPC (JAX-RPC) programming model. Although the JAX-WS Dynamic Proxy client and the JAX-RPC stub client are both based on the Service Endpoint Interface (SEI) that is generated from a WSDL file , there is a major difference. The Dynamic Proxy client is dynamically generated at run time using the Java 5 Dynamic Proxy functionality, while the JAX-RPC-based stub client is a non-portable Java file that is generated by tooling. Unlike the JAX-RPC stub clients, the Dynamic Proxy client does not require you to regenerate a stub prior to running the client on an application server for a different vendor because the generated interface does not require the specific vendor information.

The Dynamic Proxy instances extend the java.lang.reflect.Proxy class and leverage the Dynamic Proxy function in the base Java SE Runtime Environment (JRE) 6. The client application can then provide an interface used to create the proxy instance while the runtime is responsible for dynamically creating a Java object that represents the SEI.

The Dynamic Proxy client is invoked in one of three ways:

Refer to Chapter 4 of the JAX-WS specification for more information on using Dynamic Proxy clients.
JAX-WS
Implement static JAX-WS web services clients
Develop a JAX-WS client from a WSDL file
Invoke JAX-WS web services asynchronously


Related


Web services specifications and APIs
Java API for XML Web Services (JAX-WS) API documentation
Java API for XML Web Services (JAX-WS) API User's Guide documentation

+

Search Tips   |   Advanced Search