ServiceMix CXF BC
ServiceMix ships with a JBI compliant HTTP/SOAP or JMS/SOAP binding component named servicemix-cxf-bc which use 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
Maven Archetype
This archetype creates a CXF BC Service Unit, including consumer and provider sample:
Code Block |
---|
mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-cxf-bc-service-unit -DarchetypeVersion=2010.01 \ -DgroupId=your.group.id \ -DartifactId=your.artifact.id \ -Dversion=your-version |
Once you've customized the service unit, simply install the SU:
Code Block |
---|
mvn install |
Info | ||
---|---|---|
Remember that to be deployable in ServiceMix, the ServiceUnit has to be embedded in a Service Assembly: only the Service Assembly zip file can be deployed in ServiceMix.
|
Endpoints 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" targetEndpoint="CalculatorPortProxy" targetService="calculator:CalculatorService" targetInterface="calculator:CalculatorPortType"> </cxfbc:consumer> |
Info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The targetService, targetEndpoint and targetInterfaceName attributes can be used to specify the routing method to use (routing by interface, service or endpoint) and is also useful to allow several proxy endpoints to be created for the same JBI endpoint.
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 endpoint which can receive requests from the NMR and send them to a given url where the service is provided.
Here is an example of an http provider endpoint:
Code Block | ||
---|---|---|
| ||
<cxfbc:provider wsdl="/wsdl/calculator.wsdl" locationURI="http://localhost:9001/bridgetest" service="calculator:CalculatorService" endpoint="CalculatorPortProxy" interfaceName="calculator:CalculatorPortType"> </cxfbc:provider> |
Info | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
WS-Addressing
When used on a SOAP consumer endpoint, servicemix-http handles the WS-Adressing Action and To headers.
wsa:Action
The wsa:Action header can be used to specify the target interface name and operation to use for the JBI exchange.
The header uses the following syntax:
Code Block |
---|
[target namespace][delimiter][interface name][delimiter][operation name] |
where:
- [delimiter] is ":" when the [target namespace] is a URN, otherwise "/".
- [target namespace] is the namespace of the interface.
- [interface name] is the name of the interface.
- [operation name] is the name of the operation.
For example, the following header
Code Block | ||||
---|---|---|---|---|
| ||||
<wsa:Action>http://example.com/stockquote/StockQuoteInterface/GetLastTradePrice</wsa:Action> |
will be used to address the JBI exchange with the following properties:
- interface name: {http://example.com/stockquote\}StockQuoteInterface
- operation name: {http://example.com/stockquote\}GetLastTradePrice
wsa:To
The wsa:To header specifies the target JBI service name and endpoint name.
The header uses the following syntax:
Code Block |
---|
[target namespace][delimiter][service name][delimiter][endpoint name] |
where:
- [delimiter] is ":" when the [target namespace] is a URN, otherwise "/".
- [target namespace] is the namespace of the interface.
- [service name] is the name of the service.
- [endpoint name] is the name of the endpoint.
For example, the following header
Code Block | ||||
---|---|---|---|---|
| ||||
<wsa:To>urn:example:stockquote:StockQuoteService:JBIEndpoint</wsa:To> |
will be used to address the JBI exchange with the following properties:
- service name: {urn:example:stockquote}StockQuoteService
- endpoint name: JBIEndpoint
You can find a WS-Addressing test case here
More about Cxf WS-Addressing implementation
WS-Policy
You can find a WS-Policy test case
More about Cxf WS-Policy implementation
WS-Security
You can find a WS-Security test case
More about Cxf WS-Security implementation
WS-RM
You can find a WS-RM test case
More about Cxf WS-RM implementation
Interceptors Configuration
Since cxfbc is using Apache CXF internally, so you can configure cxf bc endpoint with inteceptors which follow cxf inteceptor api.
example per as below
Code Block | ||
---|---|---|
| ||
<cxfbc:consumer wsdl="..."> <cxfbc:inInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/> </cxfbc:inInterceptors> <cxfbc:outInterceptors> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> </cxfbc:outInterceptors> <cxfbc:inFaultInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/> </cxfbc:inFaultInterceptors> <cxfbc:outFaultInterceptors> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> </cxfbc:outFaultInterceptors> </cxfbc:consumer> |
Can find document for CXF interceptors here
Features configuration
You can also configure CXF features directly on 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> |