Adding a handler chain to a consumer involves explicitly building the chain of handlers. Then you set the
handler chain directly on the service proxy's Binding
object.
To add a handler chain to a consumer you do the following:
Create a List<Handler>
object to hold the handler chain.
Create an instance of each handler that will be added to the chain.
Add each of the instantiated handler objects to the list in the order they are to be invoked by the runtime.
Get the Binding
object from the service proxy.
![]() | Tip |
---|---|
FUSE Services Framework provides an implementation of the |
Set the handler chain on the proxy using the Binding
object's
setHandlerChain()
method.
Example 21.14 shows code for adding a handler chain to a consumer.
Example 21.14. Adding a Handler Chain to a Consumer
import javax.xml.ws.BindingProvider; import javax.xml.ws.handler.Handler; import java.util.ArrayList; import java.util.List; import org.apache.cxf.jaxws.binding.DefaultBindingImpl; ... SmallNumberHandler sh = new SmallNumberHandler();List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(sh);
DefaultBindingImpl binding = ((BindingProvider)proxy).getBinding();
binding.getBinding().setHandlerChain(handlerChain);
The code in Example 21.14 does the following: