By default, the Camel CXF component marshals incoming Web service requests into the POJO data form, where the In message body is encoded as a list of Java objects (one for each operation parameter). The POJO data format has advantages and disadvantages, as follows:
The big advantage of the POJO data format is that the operation parameters are encoded using the JAX-B standard, which makes them easy to manipulate in Java.
The downside of the POJO data format, on the other hand, is that it requires that the WSDL metadata is converted to Java in advance (as defined by the JAX-WS and JAX-B mappings) and compiled into your application. This means that a POJO-based route is not very dynamic.
The code presented in this chapter is taken from the following demonstration:
DemoDir/src/fuse-webinars/cxf-webinars/customer-ws-camel-cxf-pojoFor details of how to download and install the demonstration code, see Demonstration Code for Camel/CXF
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 |
|---|---|
Camel CXF endpoints—which are instantiated using the |
POJO data format is the default data format used by the Camel CXF component and it has the following characteristics:
JAX-WS and JAX-B stub code (as generated from the WSDL contract) must be provided.
The SOAP body is marshalled into a list of Java objects.
One Java object for each part or parameter of the corresponding WSDL operation.
The type of the message body is
org.apache.cxf.message.MessageContentsList.
The SOAP headers are converted into headers in the exchange's In message.
To implement and build the demonstration POJO-based route, starting from scratch, you would perform the following steps:
Obtain a copy of the WSDL contract that is to be integrated into the route.
Generate the Java stub code from the WSDL contract using a WSDL-to-Java converter. This gives you the SEI,
CustomerService, and its related classes, such asCustomer.Instantiate the Camel CXF endpoint in Spring, using the
cxf:cxfEndpointelement.Implement the route in XML, where you can use the content-based router to sort requests by operation name.
Implement the operation processor beans, which are responsible for processing each operation. When implementing these beans, the message contents must be accessed in POJO data format.
Figure 4 shows an outline of the route that is used to
process the operations of the CustomerService Web service using the POJO data
format. After sorting the request messages by operation name, an operation-specific
processor bean reads the incoming request parameters and then generates a response in the
POJO data format.






![[Note]](imagesdb/note.gif)



