Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Tip

When working with a binding that does not use special wrappers, such as the Artix ESB XML binding, payload mode and message mode provide the same results.

...

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 bellow below creates a Dispatch object that works with DOMSource objects in payload mode.

Code Block
package com.ionamycompany.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);
    ...
  }
}

Constructing request messages

...

Code Block
T invoke(T msg)
 throws WebServiceException;

...

Code Block
Response <T> invokeAsync(T msg)
 throws WebServiceException;

...

Code Block
Future<?> invokeAsync(T msg, AsyncHandler<T> handler)
 throws WebServiceException;

...

Code Block
void invokeOneWay(T msg)
 throws WebServiceException;

...

Code Block
// Creating a JAXBContext and an Unmarshaller for the request
JAXBContext jbc = JAXBContext.newInstance("orgcom.apache.cxfmycompany.StockExample");
Unmarshaller u = jbc.createUnmarshaller();

// Read the request from disk
File rf = new File("request.xml");
GetStockPrice request = (GetStockPrice)u.unmarshal(rf);

// Dispatch disp created previously
disp.invokeOneWay(request);

Operation Determination

When using a Dispatch client with a WSDL file, the operation name will be set under one of the following cases.

  • The javax.xml.ws.handler.MessageContext.WSDL_OPERATION property of the request context is set with the operation QName.
  • The addressing feature is enabled (in the bus or at the endpoint) and there is a matching operation to the payload element.
  • The "find.dispatch.operation" property of the request context is set to Boolean.TRUE and there is a matching operation to the payload element. This property is not set by default.Determining the correct operation will affect the processing such as setting the correct SOAPAction or WS-Addressing's Action.