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
Add a jaxws:handlers
child element to the endpoint's configuration element.
For each handler in the chain, add a bean
element specifying the class that implements the handler.
![]() | Tip |
---|---|
If your handler implementation is used in more than one place you can reference a |
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:endpoint
configures a service provider.
jaxws:server
also configures a service provider.
jaxws:client
configures a service consumer.
You add handlers to the handler chain in one of two ways:
add a bean
element defining the implementation class
use a ref
element to refer to a named bean
element 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>