...
ServiceMix CXF BC
ServiceMix ships with a JBI compliant HTTP/SOAP or JMS/SOAP binding component named servicemix-cxf-bc which use apache cxf Apache CXF internally.
Here are the main features:
- JBI compliant Binding Component
- Usable in a lightweight mode in servicemix.xml configuration files
- SOAP 1.1 and 1.2 support
- MIME attachments
- Support for all MEPs as consumers or providers
- SSL support
- WS-Security support
- WS-Policy support
- WS-RM support
- WS-Addressing support
Installation
...
Maven Archetype
Two archetypes are available:
- servicemix-cxf-bc
...
- -consumer-service-unit creates a CXF BC Consumer Service Unit:
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix. |
- drop the installer zip in an hotdeploy directory monitored by ServiceMix
- using ant tasks
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.
Maven Archetype
Two archetypes are available:
- servicemix-cxf-bc-consumer-service-unit creates a CXF BC Consumer Service Unit:
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-cxf-bc-consumer-service-unit
-DarchetypeVersion=2010.01 \
-DgroupId=your.group.id \
-DartifactId=your.artifact.id \
-Dversion=your-version
|
...
Code Block |
---|
mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-cxf-bc-provider-service-unit \ -DarchetypeVersion=2010.01 \ -DgroupId=your.group.id \ -DartifactId=your.artifact.id \ -Dversion=your-version |
XBean deployment
You can deploy Service Units containing a file named xbean.xml for activating consumer and provider endpoints.
This xml file should respect the given syntax, though this is a spring based xml configuration file
See a full example here. Note that you have to define the http namespace with
...
<beans xmlns:http="http://servicemix.apache.org/cxfbc/1.0">
...
</beans>
Endpoint Configuration
Consumer Endpoint
A consumer endpoint is a server-side CXF endpoint that will consume plain HTTP+SOAP requests and send them into the NMR to a given JBI endpoint, which is called the proxied endpoint.
Following is an example of an http consumer endpoint:
Code Block | ||
---|---|---|
| ||
<cxfbc:consumer wsdl="/wsdl/calculator.wsdl"
service="calculator:CalculatorService"
endpoint="CalculatorPort"
|
Any numbers of endpoints can be specified in the xbean.xml file.
Consumer endpoint
A consumer endpoint is a server-side cxf endpoint that will consume plain HTTP+SOAP requests and send them into the NMR to a given JBI endpoint, which is called the proxied endpoint.
Following is an example of an http consumer endpoint.
Code Block | ||
---|---|---|
| ||
<cxfbc:consumer wsdl="/wsdl/calculator.wsdl" servicetargetEndpoint="calculator:CalculatorServiceCalculatorPortProxy" endpointtargetService="CalculatorPortcalculator:CalculatorService" targetEndpointtargetInterface="CalculatorPortProxycalculator:CalculatorPortType"> targetService="calculator:CalculatorService" targetInterface="calculator:CalculatorPortType"> </cxfbc:consumer> </cxfbc:consumer> |
Info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
...
Note |
---|
We leverage all ws-* features from apache cxf by means of putting configuration into busCfg which is used for cxf bus initialization |
Provider
...
Endpoint
A provider endpoint is a client-side jbi JBI endpoint which can receive requests from the NMR and send them to a given url where the service is provided.
...
Info | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
It is important to note that you need to include the classpath element in your xbean.xml if you are deploying the Cxf Provider in a service unit so that the wsdl can correctly find the classpath element. Also you need to ensure that the service name and endpoint match the service and port elements of the WSDL that you wish to use to correctly return WSDL for the endpoint, remembering that the service name will use the targetNamespace for the WSDL.
Lightweight mode
The servicemix-cxf-bc component can also be configured in a spring/xbean configuration file, for use in an embedded ServiceMix.
Here is an example of such a configuration:
Code Block | ||
---|---|---|
| ||
<sm:activationSpec>
<sm:component>
<cxfbc:component>
<cxfbc:consumer wsdl="/wsdl/calculator.wsdl"
service="calculator:CalculatorService"
endpoint="CalculatorPort"
targetEndpoint="CalculatorPortProxy"
targetService="calculator:CalculatorService"
targetInterface="calculator:CalculatorPortType">
</cxfbc:consumer>
<cxfbc:provider wsdl="/wsdl/calculator.wsdl"
locationURI="http://localhost:9001/bridgetest"
service="calculator:CalculatorService"
endpoint="CalculatorPortProxy"
interfaceName="calculator:CalculatorPortType"
>
</cxfbc:provider>
</cxfbc:component>
</sm:component>
</sm:activationSpec>
|
| |||||||||||||
Warning | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
When using the servicemix.xml configuration file to create cxfbc endpoints, you must include the servicemix-cxf-bc-xxx.jar in your classpath. You will find this file inside the component installer (./components/servicemix-cxf-bc-xxx.zip). Failing this, an IllegalArgumentException will be thrown with the following message: Component name: xxxxxx is bound to an object which is not a JBI component, it is of type: javax.xml.namespace.QName |
WS-Addressing
When used on a SOAP consumer endpoint, servicemix-http handles the WS-Adressing Action and To headers.
...
Features configuration
You can also configure cxf CXF features directly on cxf bc CXF BC endpoint. Example per as below:
Code Block | ||
---|---|---|
| ||
<cxfbc:consumer wsdl="..."> <cxfbc:features> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature"> <property name="jmsConfig"> <bean class="org.apache.cxf.transport.jms.JMSConfiguration"> <property name="concurrentConsumers"> <value>5</value> </property> <property name="connectionFactory"> <ref bean="myConnectionFactory" /> </property> <property name="targetDestination"> <value>test.jmstransport.text</value> </property> <property name="useJms11"> <value>false</value> </property> </bean> </property> </bean> </cxfbc:features> </cxfbc:consumer> |