Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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

Installing the servicemix-cxf-bc component can be done in several ways:

  • 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.

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>

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.
To add your SU in a SA, you need to define it in the dependency sets:

Code Block

<dependency>
  <groupId>your.group.id</groupId>
  <artifactId>your.artifact.id</artifactId>
  <version>your-version</version>
</dependency>

Endpoints Configuration

Consumer Endpoint

Any numbers of endpoints can be specified in the xbean.xml file.

...

A consumer endpoint is a server-side cxf 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 HTTP consumer endpoint.:

Code Block
langxml
<cxfbc:consumer wsdl="/wsdl/calculator.wsdl"
                      service="calculator:CalculatorService"
                      endpoint="CalculatorPort"
                      targetEndpoint="CalculatorPortProxy"
                      targetService="calculator:CalculatorService"
                      targetInterface="calculator:CalculatorPortType">
          
</cxfbc:consumer>
Info
titleConsumer endpoint attributesEndpoint Attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Required

wsdl

String

the wsdl will be retrieved from the given location

yes

service

QName

the service name of the proxied endpoint

no (required if the WSDL has more than one service)

endpoint

String

the endpoint name of the proxied endpoint

no (required if the specified service has more than one endpoint)

interfaceName

QName

the interface name of the proxied endpoint

no

targetService

QName

the service name of the target endpoint

no (defaults to the service attribute)

targetEndpoint

String

the endpoint name of the target endpoint

no (defaults to the endpoint attribute)

targetInterfaceName

QName

the interface name of the target endpoint

no

busCfg

String

the spring configuration file used for cxf bus initialization

no

mtomEnabled

boolean

Enable MTOM / attachment support

no (defaults to false)

synchronous

boolean

Specifies if the endpoint expects send messageExchange by sendSync

no (defaults to false)

useJBIWrapper

boolean

Specifies if the endpoint expects messages to use the JBI wrapper for SOAP messages.

no (defaults to true,Ignore the value of useSOAPEnvelope if useJBIWrapper is true)

useSOAPEnvelope

boolean

Specifies if the endpoint expects soap messages when useJBIWrapper is false

no (defaults to true)

locationURI

String

Specifies the HTTP address to which requests are sent. This value will overide any value specified in the WSDL.

no (if provided the value will override the URL defined in the WSDL)

timeout

long

Specifies the interval for which the endpoint will wait for a response, This is specified in seconds.

no (defaults to 0 which means wait until response back)

x509

boolean

Specifies if the endpoint use X.509 Certificate to do the authentication.

no (defaults to false), by default we delegate AA to SMX JAASAuthenticationService with ws-security UsernameToken, if we set this flag as true, we can check for X.509 certificate to run authentication with

delegateToJaas

boolean

Specifies if the endpoint delegate to JAASAuthenticationService to do the authentication.

no (defaults to true) If we only want ws-security get involved and don't want to delegate to SMX JAASAuthenticationService then set this flag as false

schemaValidationEnabled

boolean

Specifies if the endpoint use schemavalidation for the incoming/outgoing message.

no (defaults to false)

properties

Map

Sets arbitrary properties that are added to the CXF context at the Endpoint level.

no

...

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.

...

Code Block
langxml
<cxfbc:provider wsdl="/wsdl/calculator.wsdl"
                      locationURI="http://localhost:9001/bridgetest"
                      service="calculator:CalculatorService"
                      endpoint="CalculatorPortProxy"
                      interfaceName="calculator:CalculatorPortType">

</cxfbc:provider>
Info
titleProvider endpoint attributesEndpoint Attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Required

wsdl

String

the wsdl will be retrieved from the given location

yes

service

QName

the service name of the exposed jbi endpoint

yes

endpoint

String

the endpoint name of the exposed jbi endpoint

yes

interfaceName

QName

the interface name of the exposed jbi endpoint

no

locationURI

URI

the http url of the target service

no (if provided the value will override the URL defined in the WSDL)

busCfg

String

the spring configuration file used for cxf bus initialization

no

mtomEnabled

boolean

Enable MTOM / attachment support

no (defaults to false)

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
langxml

<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>


useJBIWrapper

boolean

Specifies if the endpoint expects messages to use the JBI wrapper for SOAP messages.

no (defaults to true,Ignore the value of useSOAPEnvelope if useJBIWrapper is true)

useSOAPEnvelope

boolean

Specifies if the endpoint expects soap messages when useJBIWrapper is false

no (defaults to true)

schemaValidationEnabled

boolean

Specifies if the endpoint use schemavalidation for the incoming/outgoing message.

no (defaults to false)

properties

Map

Sets arbitrary properties that are added to the CXF context at the Endpoint level.

no

Warning
titleClasspath 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

WS-Addressing

When used on a SOAP consumer endpoint, servicemix-http handles the WS-Adressing Action and To headers.

...

Code Block
[target namespace][delimiter][interface name][delimiter][operation name]

where:

  • Wiki Markup\[delimiter\] is ":" when the \ [target namespace\] is a URN, otherwise "/".
  • Wiki Markup\[target namespace\] is the namespace of the interface. Wiki Markup
  • \[interface name\] is the name of the interface. Wiki Markup\
  • [operation name\] is the name of the operation.

For example, the following header

...

will be used to address the JBI exchange with the following properties:

  • interface name: {http://example.com/stockquote\Image Removed}StockQuoteInterface
  • operation name: {http://example.com/stockquote\Image Removed}GetLastTradePrice

...

Code Block
[target namespace][delimiter][service name][delimiter][endpoint name]

where:

  • Wiki Markup\[delimiter\] is ":" when the \ [target namespace\] is a URN, otherwise "/".unmigrated-wiki-markup
  • \[target namespace\] is the namespace of the interface.unmigrated-wiki-markup
  • \[service name\] is the name of the service. Wiki Markup\
  • [endpoint name\] is the name of the endpoint.

For example, the following header

...

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
langxml

 <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
langxml

 <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>