Chapter 40. Provider-Based Route
40.1. Provider-Based JAX-WS Endpoint
SAXSource. Since the XMLstreaming types are more efficient than DOM objects, the provider-based approach is ideal for large XML messages.
Camel CXF component
cxf:cxfEndpointXML element and are implemented by the Apache Camel project—are not to be confused with the Apache CXF JAX-WS endpoints—which are instantiated using the
jaxws:endpointXML element and are implemented by the Apache CXF project.
Provider-based approach and the PAYLOAD data format
- Define a custom
javax.xml.ws.Provider<StreamType>class, where the StreamType type is an XML streaming type, such as
- The PAYLOAD data format is selected by an annotation on the custom
Provider<?>class (see the section called “The SAXSourceService provider class”).
- The custom
Provider<?>class is referenced by setting the
serviceClassattribute of the
cxf:cxfEndpointelement in XML configuration.
- Enables you to access the message body as a streamed XML type—for example,
- No JAX-WS or JAXB stub code required.
- The SOAP body is marshalled into a stream-based
- The SOAP headers are converted into headers in the exchange's In message, of
Implementing and building a provider-based route
- Define a custom
javax.xml.ws.Provider<StreamType>class (the current demonstration uses
SAXSourceas the StreamType type).
- Instantiate the Camel CXF endpoint in Spring, using the
cxf:cxfEndpointelement and reference the custom provider class (using the
- Implement the route in XML, where you can use the content-based router to sort requests by operation name.
- For each operation, define a processor bean to process the request.
- Define velocity templates for generating the response messages.
- Define a custom type converter, to support converting a
Stringmessage body to a
Sample provider-based route
CustomerServiceWeb service using the provider-based approach. After sorting the request messages by operation name, an operation-specific processor bean reads the incoming request parameters. Finally, the response messages are generated using Velocity templates.
Figure 40.1. Sample Provider-Based Route