Skip to main content

Dispatch and Provider

Posted by kohsuke on March 1, 2007 at 5:53 PM PST

The JAX-WS RI 2.1 uses the Message class as its internal representation of a SOAP message. This interface is designed for high performance construction/access of the SOAP infoset from various sources.

This class can be extended by the applications to provide a SOAP infoset backed by a different data structure, but there are also a wide variety of default implementations that are optimized for various backend data store, such as JAXB objects, XMLStreamReader, etc.

For most applications, using the JAX-WS RI through the JAX-WS API makes the most sense, but if you are building a framework around the JAX-WS RI, you might find it more efficient to send/receive this Message object directly.

To make this possible, I just modified the RI so that it supports Dispatch (so that on the client side you can send arbitrary Message and receive one), and Provider (so that you can implement a service that receives Message and respond with one.)

A Dispatch can be created just like you create other Dispatchs, that is:

Dispatch<Message> disp = service.createDispatch(portName,Message.class,Mode.MESSAGE);

Similarly a provider service can be developed like:

@WebService
public class AddNumbersImpl implements Provider<Message> {
    @Resource
    protected WebServiceContext wsContext;

    public Messageinvoke(Message request) {
        ...
    }
}

Using Message, for example, you can construct a SOAP infoset from XMLStreamReader and send it to the remote service without ever buffering the whole SOAP infoset on memory at any given point.

Related Topics >>