이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 29. CXF Bean Component


CXF Bean Component (2.0 or later)

The cxfbean: component allows other Camel endpoints to send exchange and invoke Web service bean objects. Currently, it only supports JAXRS and JAXWS (new to Camel 2.1) annotated service beans.
Important
CxfBeanEndpoint is a ProcessorEndpoint so it has no consumers. It works similarly to a Bean component.

URI format

cxfbean:serviceBeanRef
Copy to Clipboard Toggle word wrap
Where serviceBeanRef is a registry key to look up the service bean object. If serviceBeanRef references a List object, elements of the List are the service bean objects accepted by the endpoint.

Options

Expand
Name Description Example Required? Default Value
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
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 DefaultCxfBeanBinding
headerFilterStrategy Header filter strategy specified by the # notation. The referenced object must be an instance of org.apache.camel.spi.HeaderFilterStrategy. headerFilterStrategy=#strategyName No CxfHeaderFilterStrategy
populateFromClass Since 2.3, the wsdlLocation annotated in the POJO is ignored (by default) unless this option is set to false. Prior to 2.3, the wsdlLocation annotated in the POJO is always honored and it is not possible to ignore. true, false No true
providers Since 2.5, setting the providers for the CXFRS endpoint. providers=#providerRef1,#providerRef2 No null
setDefaultBus Will set the default bus when CXF endpoint create a bus by itself. true, false No false

Headers

Expand
Name Description Type Required? Default Value In/Out Examples
CamelHttpCharacterEncoding (before 2.0-m2: CamelCxfBeanCharacterEncoding) Character encoding String No None In ISO-8859-1
CamelContentType (before 2.0-m2: CamelCxfBeanContentType) Content type String No \**/*\* In text/xml
CamelHttpBaseUri (2.0-m3 and before: CamelCxfBeanRequestBasePath)
The value of this header will be set in the CXF message as the Message.BASE_PATH property. It is needed by CXF JAX-RS 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
CamelHttpPath (before 2.0-m2: CamelCxfBeanRequestPat{}h) Request URI's path String Yes None In consumer/123
CamelHttpMethod (before 2.0-m2: CamelCxfBeanVerb) RESTful request verb String Yes None In GET, PUT, POST, DELETE
CamelHttpResponseCode HTTP response code Integer No None Out 200
Note
Currently, CXF Bean component has (only) been tested with Jetty HTTP component it can understand headers from Jetty HTTP component without requiring conversion.

A Working Sample

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 follows. 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.
<route>
	<from uri="jetty:http://localhost:9000?matchOnUriPrefix=true" />
	<to uri="cxfbean:customerServiceBean" />
	<to uri="mock:endpointA" />
</route>
Copy to Clipboard Toggle word wrap
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>

<bean class="org.apache.camel.wsdl_first.PersonImpl" id="jaxwsBean" />
Copy to Clipboard Toggle word wrap
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}}", CxfUtils.getStringFromInputStream(in));
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat