Skip to main content Skip to complementary content

Creating a Dispatch object

About this task

To create a Dispatch object do the following:

Procedure

  1. Create a Service object to represent the wsdl:service element defining the service on which the Dispatch object will make invocations.
  2. Create the Dispatch object using the Service object's createDispatch() method.
    public Dispatch<T> createDispatch(QName portName, 
       java.lang.Class<T> type, Service.Mode mode) throws WebServiceException;
    Information noteNote:

    If you are using JAXB objects the method signature for createDispatch() is:

    public Dispatch<T> createDispatch(QName portName, 
       javax.xml.bind.JAXBContext context, Service.Mode mode)
       throws WebServiceException;

Results

The following table describes the parameters for createDispatch() .

Parameter

Description

portName

Specifies the QName of the wsdl:port element that represent the service provider on which the Dispatch object will make invocations.

type

Specifies the data type of the objects used by the Dispatch object.

mode

Specifies the usage mode for the Dispatch object.

The code below creates a Dispatch object that works with DOMSource objects in payload mode.

package com.mycompany.demo;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

public class Client {
   public static void main(String args[]) {
      QName serviceName = new QName("http://org.apache.cxf", 
         "stockQuoteReporter");
      Service s = Service.create(serviceName);

      QName portName = new QName("http://org.apache.cxf", 
         "stockQuoteReporterPort");
      Dispatch<DOMSource> dispatch = s.createDispatch(portName,
         DOMSource.class,
         Service.Mode.PAYLOAD);
   ...
  }
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!