Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
41.10. Configuring Endpoints to Use Handlers
41.10.1. Programmatic Configuration Copia collegamentoCollegamento copiato negli appunti!
41.10.1.1. Adding a Handler Chain to a Consumer Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
Binding object.
Procedure Copia collegamentoCollegamento copiato negli appunti!
- 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
Bindingobject from the service proxy.TipApache CXF provides an implementation of theBindinginterface calledorg.apache.cxf.jaxws.binding.DefaultBindingImpl. - Set the handler chain on the proxy using the
Bindingobject'ssetHandlerChain()method.
Example Copia collegamentoCollegamento copiato negli appunti!
Example 41.14. Adding a Handler Chain to a Consumer
41.10.1.2. Adding a Handler Chain to a Service Provider Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
@HandlerChain annotation. The annotation points to a meta-data file defining the handler chain used by the service provider.
Procedure Copia collegamentoCollegamento copiato negli appunti!
- Decorate the provider's implementation class with the
@HandlerChainannotation. - Create a handler configuration file that defines the handler chain.
The @HandlerChain annotation Copia collegamentoCollegamento copiato negli appunti!
javax.jws.HandlerChain annotation decorates service provider's implementation class. It instructs the runtime to load the handler chain configuration file specified by its file property.
- a URL
- a relative path name
handlers.xml. handlers.xml must be located in the directory from which the service provider is run.
Example 41.15. Service Implementation that Loads a Handler Chain
Handler configuration file Copia collegamentoCollegamento copiato negli appunti!
http://java.sun.com/xml/ns/javaee.
handler-chains element. The handler-chains element has one or more handler-chain elements.
handler-chain element define a handler chain. Table 41.1, “Elements Used to Define a Server-Side Handler Chain” describes the handler-chain element's children.
| Element | Description |
|---|---|
handler | Contains the elements that describe a handler. |
service-name-pattern | Specifies the QName of the WSDL service element defining the service to which the handler chain is bound. You can use * as a wildcard when defining the QName. |
port-name-pattern | Specifies the QName of the WSDL port element defining the endpoint to which the handler chain is bound. You can use * as a wildcard when defining the QName. |
protocol-binding |
Specifies the message binding for which the handler chain is used. The binding is specified as a URI or using one of the following aliases:
##SOAP11_HTTP, ##SOAP11_HTTP_MTOM, ##SOAP12_HTTP, ##SOAP12_HTTP_MTOM, or ##XML_HTTP.
For more information about message binding URIs see Appendix C, Apache CXF Binding IDs.
|
handler-chain element is only required to have a single handler element as a child. It can, however, support as many handler elements as needed to define the complete handler chain. The handlers in the chain are executed in the order they specified in the handler chain definition.
protocol-binding, are used to limit the scope of the defined handler chain. For example, if you use the service-name-pattern element, the handler chain will only be attached to service providers whose WSDL port element is a child of the specified WSDL service element. You can only use one of these limiting children in a handler element.
handler element defines an individual handler in a handler chain. Its handler-class child element specifies the fully qualified name of the class implementing the handler. The handler element can also have an optional handler-name element that specifies a unique name for the handler.
Example 41.16. Handler Configuration File
41.10.2. Spring Configuration Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
jaxwxs:handlers child to the element configuring the endpoint.
Procedure Copia collegamentoCollegamento copiato negli appunti!
- If the endpoint does not already have a configuration element, add one.For more information on configuring Apache CXF endpoints see Chapter 15, Configuring JAX-WS 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.TipIf your handler implementation is used in more than one place you can reference abeanelement using therefelement.
The handlers element Copia collegamentoCollegamento copiato negli appunti!
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.
- add a
beanelement defining the implementation class - use a
refelement to refer to a namedbeanelement from elsewhere in the configuration file
Example Copia collegamentoCollegamento copiato negli appunti!
Example 41.17. Configuring an Endpoint to Use a Handler Chain In Spring