Java Reference
In-Depth Information
payloadsasXML,andisknownasa dispatch client .Aswith Provider , Dispatch
offers a T invoke(T) method. Dispatch clients call this method to send messages
synchronouslytoproviders,andtoobtainproviderresponsesfromthismethod'sreturn
value.
Note Dispatch offers additional invocation methods, such as Response<T>
invokeAsync(T msg) for invoking the Provider 's invoke() method asyn-
chronously. This method returns immediately; the result of the Provider 's in-
voke() method is made available in the returned Response<T> object at some
point in the future —the javax.xml.ws.Response interface extends the
java.util.concurrent.Future<T> interface, which I discuss in Chapter 6 .
A dispatch client obtains an object whose class implements Dispatch<T> by
invoking one of Service 's createDispatch() methods. For example, Dis-
patch<T> createDispatch(QName portName, Class<T> type, Ser-
vice.Mode mode) returns a Dispatch instance for communicating with the
web service through the port identified by portName , using the specified Source ,
SOAPMessage , or DataSource counterpart to the actual type argument passed to
Provider<T> , and via the service mode (message or payload) passed to mode .
Afterthe Dispatch instancehasbeenobtained,adispatchclientwillcreateanob-
ject conforming to the actual type argument passed to T , and pass this instance to the
web service provider in a call to Dispatch 's invoke() method. To understand the
interplaybetweenadispatchclientandaprovider,consideraclientthatinvokes Dis-
patch<Source> 's invoke() method with an XML document made available via
the Source argument. The following sequence occurs:
• The provider's JAX-WS runtime dispatches the client request to Provider-
<Source> 's invoke() method.
• The provider transforms the Source instance into an appropriate
javax.xml.transform.Result instance (such as a DOM tree), pro-
cessesthis Result instanceinsomemanner,andreturnsa Source instance
containing XML content to JAX-WS, which transmits the content to Dis-
patch 's invoke() method.
Dispatch 's invoke() methodreturnsanother Source instancecontaining
the XML content, which the dispatch client transforms into an appropriate
Result instance for processing.
Search WWH ::




Custom Search