The cxf: component provides integration with Apache CXF for connecting to JAX-WS services hosted in CXF.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cxf</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>
cxf://address?options
Where address represents the CXF endpoint's address
cxf:bean:cxfEndpoint
Where cxfEndpoint represents the spring bean's name which presents the CXF endpoint
For either style above, you can append options to the URI as follows:
cxf:bean:cxfEndpoint?wsdlURL=wsdl/hello_world.wsdl&dataFormat=PAYLOAD
Name | Description | Example | Required? | default value |
---|---|---|---|---|
wsdlURL | The location of the WSDL. | file://local/wsdl/hello.wsdl or wsdl/hello.wsdl | No | WSDL is obtained from endpoint address by default |
serviceClass | The name of the SEI(Service Endpoint Interface) class. This class can have but does not require JSR181 annotations. | org.apache.camel.Hello | Yes | |
serviceClassInstance | In 1.6 or later (will be deprecated in 2.0), serviceClassInstance works like serviceClass=#beanName, which looks up a serviceObject instance from the registry. | serviceClassInstance=beanName | No (use either serviceClass or serviceClassInstance) | |
serviceName | The service name this service is implementing, it maps to the wsdl:service@name. | \{http://org.apache.camel} | Only if more than one serviceName in WSDL present | |
portName | The port name this service is implementing, it maps to the wsdl:port@name. | \{http://org.apache.camel} | Only if more than one portName under the serviceName is present | |
dataFormat | Which data type messages the CXF endpoint supports | POJO, PAYLOAD, MESSAGE | No | POJO |
relayHeaders | Available since 1.6.1. Please see the Description of relayHeaders option section for this option in 2.0. Should a CXF endpoint relay headers along the route. Currently only available when dataFormat=POJO | true, false | No | true |
wrapped | Which kind of operation that CXF endpoint producer will invoke | true, false | No | false |
setDefaultBus | Will set the default bus when CXF endpoint create a bus by itself | true, false | No | false |
bus | New in 2.0, use # notation to reference a bus object from the registry. The referenced object must be an instance of org.apache.cxf.Bus. | bus=#busName | No | Default bus created by CXF Bus Factory |
cxfBinding | New in 2.0, use # notation to reference a CXF binding object from the registry. The referenced object must be an instance of org.apache.camel.component.cxf.CxfBinding. | cxfBinding=#bindingName | No | An instance of org.apache.camel.component.cxf.DefaultCxfBinding |
headerFilterStrategy | New in 2.0, use # notation to reference a header filter strategy object from the registry. The referenced object must be an instance of org.apache.camel.spi.HeaderFilterStrategy. | headerFilterStrategy=#strategyName | No | An instance of org.apache.camel.component.cxf.CxfHeaderFilterStrategy |
The serviceName
and portName
are QNames, so if you provide them
be sure to prefix them with their {namespace}
as shown in the examples
above.
NOTE From FUSE Mediation Router 1.5.1 , the serviceClass for CXF producer (i.e. the "to" endpoint) should be Java interface.
DataFormat | Description |
---|---|
POJO | POJOs (Plain old Java objects) are the Java parameters to the method being invoked on the target server. Both Protocol and Logical JAX-WS handlers are supported. |
PAYLOAD | PAYLOAD is the message payload (the contents of the soap:body) after message configuration in the CXF endpoint is applied. Only Protocol JAX-WS handler is supported. Logical JAX-WS handler is not supported. |
MESSAGE | MESSAGE is the raw message that is received from the transport layer. JAX-WS handler is not supported. |
You can determine the data format mode of an exchange by retrieving the exchange property CamelCXFDataFormat. The exchange key constant is defined in org.apache.camel.component.cxf.CxfConstants.DATA_FORMAT_PROPERTY.
CXF's LoggingOutInterceptor outputs outbound message that goes on the wire to logging system (Java Util Logging). Since the LoggingOutInterceptor is in PRE_STREAM phase (but PRE_STREAM phase is removed in MESSAGE mode), you have to configure LoggingOutInterceptor to be run at write phase. The following is an example.
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"> <!-- it really should have been user-prestream but CXF does have such phase! --> <constructor-arg value="write"/> </bean> <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9002/helloworld" serviceClass="org.apache.camel.component.cxf.HelloService"> <cxf:outInterceptors> <ref bean="loggingOutInterceptor"/> </cxf:outInterceptors> <cxf:properties> <entry key="dataFormat" value="MESSAGE"/> </cxf:properties> </cxf:cxfEndpoint>
There are "in-band" and "out-of-band" on the wire headers from a perspective of a JAXWS WSDL-first developer.
The "in-band" headers are headers that are explicitly defined as part of the WSDL binding contract for an endpoint such as SOAP headers.
The "out-of-band" headers are headers that are serialized over the wire but are not explicitly part of the WSDL binding contract.
Headers relaying/filtering is bi-directional.
When a route has a CXF endpoint and the developer needs to have on the wire headers such as SOAP headers be relayed along the route to be consumed say by another JAXWS endpoint then relayHeaders should be set to true, which is the default value.
The relayHeaders = true express an intent to relay the headers. The actual decision on whether a given header is relayed is delegated to a pluggable instance that implements MessageHeadersRelay interface. An concrete implementation MessageHeadersRelay will be consulted to decide if a header needs to be relayed or not. There is already an implementation of SoapMessageHeadersRelay which binds itself to well known SOAP name spaces. Currently only "out-of-band" headers are filtered, and "in-band" headers will always be relayed when relayHeaders = true. If there is a header on the wire, whose name space is unknown to the runtime, then a fall back DefaultMessageHeadersRelay will be used, which simply allows all headers to be relayed.
The relayHeaders = false asserts that all headers "in-band" and "out-of-band" will be dropped.
You can plugin your own MessageHeadersRelay implementations overriding or adding additional ones to the list of relays. In order to override a preloaded relay instance just make sure that your MessageHeadersRelay implementation services the same name spaces as the one you looking to override. Also note, that the overriding relay has to service all of the name spaces as the one you looking to override, or else a runtime exception on route start up will be thrown as this would introduce an ambiguity in name spaces to relay instance mappings.
<cxf:cxfEndpoint ...> <cxf:properties> <entry key="org.apache.camel.cxf.message.headers.relays"> <list> <ref bean="customHeadersRelay"/> </list> </entry> </cxf:properties> </cxf:cxfEndpoint> <bean id="customHeadersRelay" class="org.apache.camel.component.cxf.soap.headers.CustomHeadersRelay"/>
Take a look at the tests that show how you'd be able to relay/drop headers here:
https://svn.apache.org/repos/asf/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
POJO and PAYLOAD modes are supported. In POJO mode, only out-of-band message headers are available for filtering as the in-band headers has been processed and removed from header list by CXF. The in-band headers are incorporated into the MessageContentList in POJO mode. The camel-cxf component does make any attempt to remove the in-band headers from the MessageContentList as it does in 1.6.1. If filtering in-band headers is required, please you PAYLOAD mode or plug in a (pretty straight forward) CXF interceptor/JAXWS Handler to the CXF endpoint.
The Message Header Relay mechanism has been merged into CxfHeaderFilterStrategy. The relayHeaders option, its semantics, and default value remain the same but it is a property of CxfHeaderFilterStrategy.
Here is an example of configuring it.
<bean id="dropAllMessageHeadersStrategy" class="org.apache.camel.component.cxf.CxfHeaderFilterStrategy"> <!-- Set relayHeaders to false to drop all SOAP headers --> <property name="relayHeaders" value="false"/> </bean>
Then, your endpoint can reference the CxfHeaderFilterStrategy.
<route> <from uri="cxf:bean:routerNoRelayEndpoint?headerFilterStrategy=#dropAllMessageHeadersStrategy"/> <to uri="cxf:bean:serviceNoRelayEndpoint?headerFilterStrategy=#dropAllMessageHeadersStrategy"/> </route>
The MessageHeadersRelay interface has changed slightly and has been renamed to MessageHeaderFilter. It is a property of CxfHeaderFilterStrategy. Here is an example of configuring user defined Message Header Filters.
<bean id="customMessageFilterStrategy" class="org.apache.camel.component.cxf.CxfHeaderFilterStrategy"> <property name="messageHeaderFilters"> <list> <!-- SoapMessageHeaderFilter is the built in filter. It can be removed by omitting it. --> <bean class="org.apache.camel.component.cxf.SoapMessageHeaderFilter"/> <!-- Add custom filter here --> <bean class="org.apache.camel.component.cxf.soap.headers.CustomHeaderFilter"/> </list> </property> </bean>
Other than relayHeaders, there are new properties that can be configured in CxfHeaderFilterStrategy.
Name | Description | type | Required? | Default value |
---|---|---|---|---|
relayHeaders | all message headers will be processed by Message Header Filters | boolean | no | true (1.6.1 behavior) |
relayAllMessageHeaders | all message headers will be propagated (without processing by Message Header Filters) | boolean | no | false (1.6.1 behavior) |
allowFilterNamespaceClash | if two filters overlap in activation namespace, the property control how it should be handled. If the value is true, last one wins. If the value is false, it will throw an exception | boolean | no | false (1.6.1 behavior) |
You can configure the CXF endpoint with the below spring configuration file, and you can also embed the endpoint into the camelContext tags.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/camel-cxf-1.6.0.xsd http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd "> <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9003/CamelContext/RouterPort" serviceClass="org.apache.hello_world_soap_http.GreeterImpl"/> <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort" wsdlURL="testutils/hello_world.wsdl" serviceClass="org.apache.hello_world_soap_http.Greeter" endpointName="s:SoapPort" serviceName="s:SOAPService" xmlns:s="http://apache.org/hello_world_soap_http" /> <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="cxf:bean:routerEndpoint" /> <to uri="cxf:bean:serviceEndpoint" /> </route> </camelContext> </beans>
NOTE In FUSE Mediation Router 2.x we change to use "http://camel.apache.org/schema/cxf" as the cxfendpont's target namespace.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/cxf" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf-2.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> ...
Be sure to include the JAX-WS schemaLocation
attribute specified on
the root beans element. This allows CXF to validate the file and is required. Also note
the namespace declarations at the end of the <cxf:cxfEndpoint/> tag--these are
required because the combined "\{namespace}localName" syntax is presently not supported
for this tag's attribute values.
The cxf:cxfEndpoint
element supports many additional
attributes:
Name | Value |
---|---|
PortName | The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of "ns:PORT_NAME" where ns is a namespace prefix valid at this scope. |
serviceName | The service name this service is implementing, it maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope. |
wsdlURL | The location of the WSDL. Can be on the classpath, file system, or be hosted remotely. |
bindingId | The bindingId for the service model to use |
address | The service publish address |
bus | The bus name that will be used in the jaxws endpoint. |
serviceClass | The class name of the SEI(Service Endpoint Interface) class which could have JSR181 annotation or not |
It also supports many child elements:
Name | Value |
---|---|
cxf:inInterceptors | The incoming interceptors for this endpoint. A list of <bean>s or <ref>s. |
cxf:inFaultInterceptors | The incoming fault interceptors for this endpoint. A list of <bean>s or <ref>s. |
cxf:outInterceptors | The outgoing interceptors for this endpoint. A list of <bean>s or <ref>s. |
cxf:outFaultInterceptors | The outgoing fault interceptors for this endpoint. A list of <bean>s or <ref>s. |
cxf:properties | A properties map which should be supplied to the JAX-WS endpoint. See below. |
cxf:handlers | A jaxws handler list which should be supplied to the JAX-WS endpoint. See below. |
cxf:dataBinding | You can specify the which DataBinding will be use in the endpoint, This can be supplied using the Spring <bean class="MyDataBinding"/> syntax. |
cxf:binding | You can specify the BindingFactory for this endpoint to use. This can be supplied using the Spring <bean class="MyBindingFactory"/> syntax. |
cxf:features | The features that hold the interceptors for this endpoint. A list of <bean>s or <ref>s |
cxf:schemaLocations | The schema locations for endpoint to use. A list of <schemaLocation>s |
cxf:serviceFactory | The service factory for this endpoint to use. This can be supplied using the Spring <bean class="MyServiceFactory"/> syntax |
You can find more advanced examples which show how to provide interceptors , properties and handlers here: http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html
NOTE You can use cxf:properties to set the camel-cxf endpoint's dataFormat and setDefaultBus properties from spring configuration file.
<cxf:cxfEndpoint id="testEndpoint" address="http://localhost:9000/router" serviceClass="org.apache.camel.component.cxf.HelloService" endpointName="s:PortName" serviceName="s:ServiceName" xmlns:s="http://www.example.com/test"> <cxf:properties> <entry key="dataFormat" value="MESSAGE"/> <entry key="setDefaultBus" value="true"/> </cxf:properties> </cxf:cxfEndpoint>
CXF's default logger is using java.util.logging, if you want to change it to log4j. Here is the instruction: Create a file, in the classpath, named META-INF/cxf/org.apache.cxf.logger.This file should contain the fully-qualified name of the class (org.apache.cxf.common.logging.Log4jLogger), with no comments, on a single line.
The camel-cxf endpoint consumer POJO data format is based on the cxf invoker, so the message header has a property with the name of CxfConstants.OPERATION_NAME and the message body is a list of the SEI method parameters.
public class PersonProcessor implements Processor { private static final transient Log LOG = LogFactory.getLog(PersonProcessor.class); public void process(Exchange exchange) throws Exception { LOG.info("processing exchange in camel"); BindingOperationInfo boi = (BindingOperationInfo)exchange.getProperty(BindingOperationInfo.class.toString()); if (boi != null) { LOG.info("boi.isUnwrapped" + boi.isUnwrapped()); } // Get the parameters list which element is the holder. MessageContentsList msgList = (MessageContentsList)exchange.getIn().getBody(); Holder<String> personId = (Holder<String>)msgList.get(0); Holder<String> ssn = (Holder<String>)msgList.get(1); Holder<String> name = (Holder<String>)msgList.get(2); if (personId.value == null || personId.value.length() == 0) { LOG.info("person id 123, so throwing exception"); // Try to throw out the soap fault message org.apache.camel.wsdl_first.types.UnknownPersonFault personFault = new org.apache.camel.wsdl_first.types.UnknownPersonFault(); personFault.setPersonId(""); org.apache.camel.wsdl_first.UnknownPersonFault fault = new org.apache.camel.wsdl_first.UnknownPersonFault("Get the null value of person name", personFault); // Since camel has its own exception handler framework, we can't throw the exception to trigger it // We just set the fault message in the exchange for camel-cxf component handling exchange.getFault().setBody(fault); } name.value = "Bonjour"; ssn.value = "123"; LOG.info("setting Bonjour as the response"); // Set the response message, first element is the return value of the operation, // the others are the holders of method parameters exchange.getOut().setBody(new Object[] {null, personId, ssn, name}); } }
The camel-cxf endpoint producer is based on the cxf client API. First you need to specify the operation name in the message header , then add the method parameters into a list and set the message with this parameter list will be ok. The response message's body is a messageContentsList, you can get the result from that list.
NOTE After FUSE Mediation Router 1.5 , we change the message body from object array to message content list. If you still want to get the object array from the message body, you can get the body with this code message.getbody(Object\\.class)
Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut); final List<String> params = new ArrayList<String>(); // Prepare the request message for the camel-cxf procedure params.add(TEST_MESSAGE); senderExchange.getIn().setBody(params); senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION); Exchange exchange = template.send("direct:EndpointA", senderExchange); org.apache.camel.Message out = exchange.getOut(); // The response message's body is an MessageContentsList which first element is the return value of the operation, // If there are some holder parameters, the holder parameter will be filled in the reset of List. // The result will be extract from the MessageContentsList with the String class type MessageContentsList result = (MessageContentsList)out.getBody(); LOG.info("Received output text: " + result.get(0)); Map<String, Object> responseContext = CastUtils.cast((Map)out.getHeader(Client.RESPONSE_CONTEXT)); assertNotNull(responseContext); assertEquals("We should get the response context here", "UTF-8", responseContext.get(org.apache.cxf.message.Message.ENCODING)); assertEquals("Reply body on Camel is wrong", "echo " + TEST_MESSAGE, result.get(0));
PAYLOAD means you will get or set the payload message which has been take out the SOAP envelope from or into the CXF message. You can use the Header.HEADER_LIST as the key to set or get the SOAP headers and use the List<Element> to set or get SOAP body elements.
Change in 2.0, CxfMessage.getBody() will return a org.apache.camel.component.cxf.CxfPayload object, which has getters for SOAP message headers and Body elements. This change enables decoupling the native CXF message from the FUSE Mediation Router message.
from(routerEndpointURI).process(new Processor() { @SuppressWarnings("unchecked") public void process(Exchange exchange) throws Exception { CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class); List<Element> elements = payload.getBody(); assertNotNull("We should get the elements here", elements); assertEquals("Get the wrong elements size", 1, elements.size()); assertEquals("Get the wrong namespace URI", "http://camel.apache.org/pizza/types", elements.get(0).getNamespaceURI()); List<SoapHeader> headers = payload.getHeaders(); assertNotNull("We should get the headers here", headers); assertEquals("Get the wrong headers size", headers.size(), 1); assertEquals("Get the wrong namespace URI", ((Element)(headers.get(0).getObject())).getNamespaceURI(), "http://camel.apache.org/pizza/types"); } }) .to(serviceEndpointURI);
If you are using the camel-cxf endpoint to consume the SOAP request, you may need to throw the SOAP Fault from the camel context. Basically, you can use the throwFault DSL to do that, it works for POJO, PAYLOAD and MESSAGE data format. You can define the soap fault like this
SOAP_FAULT = new SoapFault(EXCEPTION_MESSAGE, SoapFault.FAULT_CODE_CLIENT); Element detail = SOAP_FAULT.getOrCreateDetail(); Document doc = detail.getOwnerDocument(); Text tn = doc.createTextNode(DETAIL_TEXT); detail.appendChild(tn);
Then throw it as you like
from(routerEndpointURI).throwFault(SOAP_FAULT);
If your cxf endpoint working in the MESSAGE data format, you could set the the SOAP Fault message into the message body and set the response code in the message header.
from(routerEndpointURI).process(new Processor() { public void process(Exchange exchange) throws Exception { Message out = exchange.getOut(); // Set the message body with the out.setBody(this.getClass().getResourceAsStream("SoapFaultMessage.xml")); // Set the response code here out.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); } });
NOTE the response code setting only works in FUSE Mediation Router's version >= 1.5.1
cxf client API provides a way to invoke the operation with request and response context. If you are using camel-cxf endpoint producer to invoke the outside web service, you can set the request context and get response context with below codes.
CxfExchange exchange = (CxfExchange)template.send(getJaxwsEndpointUri(), new Processor() { public void process(final Exchange exchange) { final List<String> params = new ArrayList<String>(); params.add(TEST_MESSAGE); // Set the request context to the inMessage Map<String, Object> requestContext = new HashMap<String, Object>(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, JAXWS_SERVER_ADDRESS); exchange.getIn().setBody(params); exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext); exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, GREET_ME_OPERATION); } }); org.apache.camel.Message out = exchange.getOut(); // The output is an object array, the first element of the array is the return value Object[] output = out.getBody(Object[].class); LOG.info("Received output text: " + output[0]); // Get the response context form outMessage Map<String, Object> responseContext = CastUtils.cast((Map)out.getHeader(Client.RESPONSE_CONTEXT)); assertNotNull(responseContext); assertEquals("Get the wrong wsdl opertion name", "{http://apache.org/hello_world_soap_http}greetMe", responseContext.get("javax.xml.ws.wsdl.operation").toString());
The cxfbean: component allows other FUSE Mediation Router endpoint to send exchange and invoke web service bean objects. (Currently, it only supports JAXRS annotated service bean.)
Note: CxfBeanEndpoint is a ProcessorEndpoint so it has no Consumers. It works similar to a Bean component.
cxfbean:serviceBeanRef
Where serviceBeanRef is a registry key to looks service bean object. If serviceBeanRef references to a List, elements of the List are the service bean objects accepted by the endpoint.
Name | Description | Example | Required? | default value |
---|---|---|---|---|
cxfBeanBinding | CXF bean binding specified by the "#" notation. The referenced object must be an instance of org.apache.camel.component.cxf.cxfbean.CxfBeanBinding. | cxfBinding=#bindingName | No | An instance of org.apache.camel.component.cxf.cxfbean.DefaultCxfBeanBinding |
bus | CXF bus reference specified by the "#" notation. The referenced object must be an instance of org.apache.cxf.Bus. | bus=#busName | No | Default bus created by CXF Bus Factory |
headerFilterStrategy | Header filter strategy specified by the "#" notation. The referenced object must be an instance of org.apache.camel.spi.HeaderFilterStrategy. | headerFilterStrategy=#strategyName | No | An instance of org.apache.camel.component.cxf.CxfHeaderFilterStrategy |
setDefaultBus | Will set the default bus when CXF endpoint create a bus by itself | true, false | No | false |
Name | Description | type | Required? | Default value | in/out | Examples |
---|---|---|---|---|---|---|
CamelCxfBeanCharacterEncoding | Character encoding | String | no | none | in | ISO-8859-1 |
CamelCxfBeanContentType | Content type | String | no | \**/*\* | in | text/xml |
CamelCxfBeanRequestBasePath | The value of this header will be set in the CXF message as the Message.BASE_PATH property. It is needed by CXF JAXRS processing. Basically, it is the scheme, host and port portion of the request URI. | String | yes | the Endpoint URI of the source endpoint in the Camel exchange | in | http://localhost:9000 |
CamelCxfBeanRequestPath | Request URI's path | String | yes | none | in | consumer/123 |
CamelCxfBeanVerb | RESTful request verb | String | yes | none | in | GET, PUT, POST, DELETE |
Note: Currently, CXF Bean component has (only) been tested with Jetty HTTP component it can understand headers from Jetty HTTP component without requiring conversion.
This sample shows how to create a route that starts a Jetty HTTP server. The route sends requests to a CXF Bean and invokes a JAXRS annotated service.
First, create a route as the following. The "from" endpoint is a Jetty HTTP endpoint that is listening on port 9000. Notice that the matchOnUriPrefix option must be set to true because RESTful request URI will not match the endpoint's URI "http://localhost:9000" exactly.
from("jetty:http://localhost:9000?matchOnUriPrefix=true"). to("cxfbean:customerServiceBean");
The "to" endpoint is a CXF Bean with bean name "customerServiceBean". The name will be looked up from the registry. Next, we make sure our service bean is available in Spring registry. We create a bean definition in the Spring configuration. In this example, we create a List of service beans (of one element). We could have created just a single bean without a List.
<util:list id="customerServiceBean"> <bean class="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" /> </util:list>
That's it. Once the route is started, the web service is ready for business. A HTTP client can make a request and receive response.
url = new URL("http://localhost:9000/customerservice/orders/223/products/323"); in = url.openStream(); assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", getStringFromInputStream(in));