LibraryLink ToToggle FramesPrintFeedback

Adding a Handler Chain to a Consumer

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:

Example 21.14 shows code for adding a handler chain to a consumer.

Example 21.14. Adding a Handler Chain to a Consumer

import java.util.ArrayList;
import java.util.List;

import org.apache.cxf.jaxws.binding.DefaultBindingImpl;
SmallNumberHandler sh = new SmallNumberHandler(); 1
List<Handler> handlerChain = new ArrayList<Handler>(); 2
handlerChain.add(sh); 3

DefaultBindingImpl binding = ((BindingProvider)proxy).getBinding(); 4
binding.getBinding().setHandlerChain(handlerChain); 5

The code in Example 21.14 does the following:


Instantiates a handler.


Creates a List object to hold the chain.


Adds the handler to the chain.


Gets the Binding object from the proxy as a DefaultBindingImpl object.


Assigns the handler chain to the proxy's binding.