In Apache Camel, the Camel CXF component is the key to integrating routes with Web services. You can use the Camel CXF component to create two different kinds of Apache Camel endpoint:
Consumer endpoint—(at the start of a route) represents a Web service instance, which integrates with the route. The type of payload injected into the route depends on the value of the endpoint's
dataFormatoption.Producer endpoint—represents a special kind of WS client proxy, which converts the current exchange object into an operation invocation on a remote Web service. The format of the current exchange must match the endpoint's
dataFormatsetting.
The cxf:bean: URI is used to bind an Apache CXF endpoint to a route and has the
following general syntax:
cxf:bean:CxfEndpointID[?Options]
Where is the ID of a bean created
using the CxfEndpointIDcxf:cxfEndpoint element, which configures the details of the WS
endpoint. You can append options to this URI (where the options are described in detail in
CXF in Apache Camel Documentation). To enable payload
mode, you must set the URI option, dataFormat=PAYLOAD.
For example, to start a route with an endpoint in PAYLOAD mode, where the endpoint is
configured by the customer-ws bean, define the route as follows:
<route>
<from uri="cxf:bean:customer-ws?dataFormat=PAYLOAD"/>
...
</route>The cxf:cxfEndpoint element is used to define a WS endpoint that binds
either to the start (consumer endpoint) or the end (producer endpoint) of a route. For
example, to define the customer-ws WS endpoint in PAYLOAD mode, you define a
cxf:cxfEndpoint element as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
...
<cxf:cxfEndpoint id="customer-ws"
address="http://0.0.0.0:9191/Customer"
endpointName="c:SOAPOverHTTP"
serviceName="c:CustomerService"
wsdlURL="wsdl/CustomerService.wsdl"
xmlns:c="http://demo.fusesource.com/wsdl/CustomerService/"/>
...
</beans>![]() | Note |
|---|---|
In the case of PAYLOAD mode, you do not need to reference the SEI and you must specify the WSDL location instead. In fact, in PAYLOAD mode, you do not require any Java stub code at all. |
Apache CXF deploys the WS endpoint into a Jetty servlet container instance and the address attribute of
cxf:cxfEndpoint is therefore used to configure the addressing information for
the endpoint in the Jetty container.
Specify a complete HTTP URL, including the host and IP port (the value of the IP port
effectively identifies the target Jetty container). Typically, for a Jetty container, you
specify the host as 0.0.0.0, which is interpreted as a wildcard that matches
every IP network interface on the local machine (that is, if deployed on a multi-homed host,
Jetty opens a listening port on every network card). For example, to deploy the endpoint to
the custom Jetty container listening on IP port, 9191:
address="http://0.0.0.0:9191/Customers"
![]() | Note |
|---|---|
If you want to configure a secure endpoint (secured by SSL), you would specify the
|
The wsdlURL attribute of the cxf:cxfEndpoint element is used
to specify the location of the WSDL contract for this endpoint. The WSDL contract is used
exclusively as the source of metadata for this endpoint: there is need to specify an SEI in
PAYLOAD mode.
Because of the modular structure of Apache CXF, additional configuration is added as needed
using the relevant <import ...> tags in XML. In the most recent version of
Apache CXF (later than 2.4.3), only the META-INF/cxf/cxf.xml resource is
needed.
For more details, see Importing XML resources.






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


