... |
[here|http://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMSequenceTest.java] h3. More about [Cxf WS-RM|http://cwiki.apache.org/CXF20DOC/ws-reliablemessaging.html] implementation |
h2. Interceptors Configuration Since cxfbc is using [Apache CXF|http://cxf.apache.org/] internally, so you can configure cxf bc endpoint with inteceptors which follow cxf inteceptor api. example per as below {code:lang=xml} <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> {code} Can find document for CXF interceptors [here|http://cwiki.apache.org/confluence/display/CXF20DOC/Interceptors] h2. Features configuration You can also configure cxf features directly on cxf bc endpoint. Example per as below {code:lang=xml} <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> {code} |
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:
Installing the servicemix-cxf-bc component can be done in several ways:
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.
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>
Any numbers of endpoints can be specified in the xbean.xml file.
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.
<cxfbc:consumer wsdl="/wsdl/calculator.wsdl" service="calculator:CalculatorService" endpoint="CalculatorPort" targetEndpoint="CalculatorPortProxy" targetService="calculator:CalculatorService" targetInterface="calculator:CalculatorPortType"> </cxfbc:consumer>
![]() | Consumer endpoint attributes
|
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.
![]() | We leverage all ws-* features from apache cxf by means of putting configuration into busCfg which is used for cxf bus initialization |
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:
<cxfbc:provider wsdl="/wsdl/calculator.wsdl" locationURI="http://localhost:9001/bridgetest" service="calculator:CalculatorService" endpoint="CalculatorPortProxy" interfaceName="calculator:CalculatorPortType"> </cxfbc:provider>
![]() | Provider endpoint attributes
|
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.
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:
<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>
![]() | Classpath issues when embedding servicemix-cxf-bc component 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 |
When used on a SOAP consumer endpoint, servicemix-http handles the WS-Adressing Action and To headers.
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:
[target namespace][delimiter][interface name][delimiter][operation name]
where:
For example, the following header
<wsa:Action>http://example.com/stockquote/StockQuoteInterface/GetLastTradePrice</wsa:Action>
will be used to address the JBI exchange with the following properties:
The wsa:To header specifies the target JBI service name and endpoint name.
The header uses the following syntax:
[target namespace][delimiter][service name][delimiter][endpoint name]
where:
For example, the following header
<wsa:To>urn:example:stockquote:StockQuoteService:JBIEndpoint</wsa:To>
will be used to address the JBI exchange with the following properties:
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
<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
You can also configure cxf features directly on cxf bc endpoint. Example per as below
<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>