Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 40. Provider-Based Route


40.1. Provider-Based JAX-WS Endpoint

Overview

Use the provider-based approach, if you need to process very large Web services messages. The provider-based approach is a variant of the PAYLOAD data format that enables you to encode the message body as an XML streaming type, such as SAXSource. Since the XMLstreaming types are more efficient than DOM objects, the provider-based approach is ideal for large XML messages.

Demonstration location

The code presented in this chapter is taken from the following demonstration:
cxf-webinars-jboss-fuse-6.3/customer-ws-camel-cxf-provider
For details of how to download and install the demonstration code, see Chapter 34, Demonstration Code for Camel/CXF

Camel CXF component

The Camel CXF component is an Apache CXF component that integrates Web services with routes. You can use it either to instantiate consumer endpoints (at the start of a route), which behave like Web service instances, or to instantiate producer endpoints (at any other points in the route), which behave like WS clients.
Note
Came CXF endpoints—which are instantiated using the cxf:cxfEndpoint XML 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:endpoint XML element and are implemented by the Apache CXF project.

Provider-based approach and the PAYLOAD data format

The provider-based approach is a variant of the PAYLOAD data format, which is enabled as follows:
  • Define a custom javax.xml.ws.Provider<StreamType> class, where the StreamType type is an XML streaming type, such as SAXSource.
  • 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 serviceClass attribute of the cxf:cxfEndpoint element in XML configuration.
The provider-based approach has the following characteristics:
  • Enables you to access the message body as a streamed XML type—for example, javax.xml.transform.sax.SAXSource.
  • No JAX-WS or JAXB stub code required.
  • The SOAP body is marshalled into a stream-based SAXSource type.
  • The SOAP headers are converted into headers in the exchange's In message, of org.apache.cxf.binding.soap.SoapHeader type.

Implementing and building a provider-based route

To implement and build the demonstration provider-based route, starting from scratch, you would perform the following steps:
  1. Define a custom javax.xml.ws.Provider<StreamType> class (the current demonstration uses SAXSource as the StreamType type).
  2. Instantiate the Camel CXF endpoint in Spring, using the cxf:cxfEndpoint element and reference the custom provider class (using the serviceClass attribute).
  3. Implement the route in XML, where you can use the content-based router to sort requests by operation name.
  4. For each operation, define a processor bean to process the request.
  5. Define velocity templates for generating the response messages.
  6. Define a custom type converter, to support converting a String message body to a SAXSource message body.

Sample provider-based route

Figure 40.1, “Sample Provider-Based Route” shows an outline of the route that is used to process the operations of the CustomerService Web 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

Sample Provider-Based Route
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.