LibraryToggle FramesPrintFeedback

To use a Dispatch object to invoke a remote service the following sequence should be followed:

  1. Create a Dispatch object.

  2. Construct a request message.

  3. Call the proper invoke() method.

  4. Parse the response message.

To create a Dispatch object do the following:

Example 19.2 shows the code for creating a Dispatch object that works with DOMSource objects in payload mode.


When working with Dispatch objects, requests must be built from scratch. The developer is responsible for ensuring that the messages passed to a Dispatch object match a request that the targeted service provider can process. This requires precise knowledge about the messages used by the service provider and what, if any, header information it requires.

This information can be provided by a WSDL document or an XML Schema document that defines the messages. While service providers vary greatly there are a few guidelines to be followed:

For more information about how services use XML messages see, the WS-I Basic Profile.

Dispatch objects also support asynchronous invocations. As with the higher level asynchronous APIs discussed in Developing Asynchronous Applications, Dispatch objects can use both the polling approach and the callback approach.

When using the polling approach, the invokeAsync() method returns a Response<t> object that can be polled to see if the response has arrived. Example 19.5 shows the signature of the method used to make an asynchronous invocation using the polling approach.


For detailed information on using the polling approach for asynchronous invocations see Implementing an Asynchronous Client with the Polling Approach.

When using the callback approach, the invokeAsync() method takes an AsyncHandler implementation that processes the response when it is returned. Example 19.6 shows the signature of the method used to make an asynchronous invocation using the callback approach.


For detailed information on using the callback approach for asynchronous invocations see Implementing an Asynchronous Client with the Callback Approach.

[Note]Note

As with the synchronous invoke() method, the type of the response and the type of the request are determined when you create the Dispatch object.

Comments powered by Disqus
loading table of contents...