The easiest way to configure an endpoint to use a handler chain is to define the chain in the endpoint's configuration. This is
done by adding a jaxwxs:handlers child to the element configuring the endpoint.
![]() | Important |
|---|---|
A handler chain added through the configuration file takes precedence over a handler chain configured programatically. |
To configure an endpoint to load a handler chain you do the following:
If the endpoint does not already have a configuration element, add one.
For more information on configuring Fuse Services Framework endpoints see Configuring JAX-WS Endpoints in Configuring and Deploying Web Service Endpoints.
Add a
jaxws:handlerschild element to the endpoint's configuration element.For each handler in the chain, add a
beanelement specifying the class that implements the handler.![[Tip]](imagesdb/tip.gif)
Tip If your handler implementation is used in more than one place you can reference a
beanelement using therefelement.
The jaxws:handlers element defines a handler chain in an endpoint's configuration. It can appear as a child to all of the JAX-WS
endpoint configuration elements. These are:
jaxws:endpointconfigures a service provider.jaxws:serveralso configures a service provider.jaxws:clientconfigures a service consumer.
You add handlers to the handler chain in one of two ways:
add a
beanelement defining the implementation classuse a
refelement to refer to a namedbeanelement from elsewhere in the configuration file
The order in which the handlers are defined in the configuration is the order in which they will be executed. The order may be modified if you mix logical handlers and protocol handlers. The run time will sort them into the proper order while maintaining the basic order specified in the configuration.
Example 21.17 shows the configuration for a service provider that loads a handler chain.
Example 21.17. Configuring an Endpoint to Use a Handler Chain In Spring
<beans ... xmlns:jaxws="http://cxf.apache.org/jaxws" ... schemaLocation="... http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ..."> <jaxws:endpoint id="HandlerExample" implementor="org.apache.cxf.example.DemoImpl" address="http://localhost:8080/demo"> <jaxws:handlers> <bean class="demo.handlers.common.LoggingHandler" /> <bean class="demo.handlers.common.AddHeaderHandler" /> </jaxws:handlers> </jaws:endpoint> </beans>






![[Important]](imagesdb/important.gif)


