Codehaus XFire

Documentation

Quicklinks

Developers

Sponsors

Handlers can be used to do all sorts of things with XFire. They can process the SOAP Body or they can process a particular header and take action based on it. To write a handler just extend the AbstractHandler class:

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.handler.AbstractHandler;

public class YourHandler extends AbstractHandler
{
    public void invoke(MessageContext context)
    {
        // Do some processing...
    }
}

Handlers can be registered with a Service or a Transport. On both Services and Transports you can stick a handler in a request or response pipeline:

Servic s = ...;

// Do this to add a handler to the incoming flow
s.addInHandler(new YourHandler());

// Do this to add a handler to the outgoing flow
s.addOutHandler(new YourHandler());

// Do this to add a handler to the faultflow
s.addFaultHandler(new YourHandler());

Processing SOAP Headers

If you are using the "mustUnderstand" feature of SOAP you must tell XFire which QNames you can handle:

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.handler.AbstractHandler;

public class YourHandler extends AbstractHandler
{
    ....
    public QName[] getUnderstoodHeaders()
    {
        return new QName[] { new QName("YourHeader", "urn:your:header:ns") };
    }
}