Codehaus XFire

Documentation

Quicklinks

Developers

Sponsors

The Bindings section, goes in to detail about the Aegis BindingProvider and how it forms the basis for other bindings like JAXB, XMLBeans, etc. XFire also includes a completely different type of binding called the MessageBinding.

Why another binding? Sometimes with your services, you may want to work directly with the XML. The Aegis actually allows this as well. You can use Document, Element, XMLStreamReader classes on your beans and on your service interface. But, the aegis binding assumes that we're going to take the stream and actually read it into an object. So it is impossible to work with the XMLStreamReader directly in your service interface. You are working with a copy of it.

The MessageBinding on the other takes the XMLStreamReader from the request and provides it directly to your class.

To use the message binding:

ObjectServiceFactory factory = new ObjectServiceFactory(new MessageBindingProvider());
factory.setStyle("message");

You can then easily declare a service interface which receives and returns XMLStreamReaders:

public class MyService {
  public XMLStreamReader invoke(XMLStreamReader reader) {
    // do something with the stream;
    return responseStream;
  }
}

Note that the message binding is not smart enough to dispatch messages, so you can't have more than one service method (or if you have, a random method will be called).

The binding will also allow you to work with the org.jdom.Element class.

As with all the "non-default" bindings, you have to take care to configure this correctly. In services.xml (see services.xml Reference) this might look as follows. Note the style=message and the binding provider setting.

<service>
     <name>MessageService</name>
     <namespace>http://localhost:8080/MessageBinding/services</namespace>
     <serviceClass>IMessageService</serviceClass>
     <implementationClass>MessageServiceImpl</implementationClass>
     <bindingProvider>org.codehaus.xfire.service.binding.MessageBindingProvider</bindingProvider>
     <style>message</style>
</service>