This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Sample 654: Smooks Mediator

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

Objective: Demonstrate the smooks mediatot EDI message processing.

Here is the sample with smooks mediator.

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <localEntry key="transform-xslt-key"
                src="file:samples/service-bus/resources/smooks/transform.xslt"/>
    <localEntry key="smooks-key" src="file:samples/service-bus/resources/smooks/smooks-config.xml"/>
    <proxy name="StockQuoteProxy" transports="vfs">
        <parameter name="transport.vfs.ContentType">text/plain</parameter>
        <!--CHANGE-->
        <parameter name="transport.vfs.ContentType">text/plain</parameter>
       <parameter name="transport.vfs.FileURI">file:///home/user/dev/test/smooks/in</parameter>
       <parameter name="transport.vfs.FileNamePattern">.*\.txt</parameter>
        <parameter name="transport.PollInterval">5</parameter>
        <!--CHANGE-->
        <parameter name="transport.vfs.MoveAfterProcess">file:///home/user/dev/test/smooks/original</parameter>
        <!--CHANGE-->
        <parameter name="transport.vfs.MoveAfterFailure">file:///home/user/dev/test/smooks/original</parameter>
        <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
        <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
        <parameter name="Operation">urn:placeOrder</parameter>
        <target>
            <inSequence>
                <smooks config-key="smooks-key"/>
                <xslt key="transform-xslt-key"/>
                <iterate expression="//m0:placeOrder/m0:order" preservePayload="true"
                         attachPath="//m0:placeOrder" xmlns:m0="http://services.samples">
                    <target>
                        <sequence>
                            <header name="Action" value="urn:placeOrder"/>
                            <property action="set" name="OUT_ONLY" value="true"/>
                            <send>
                                <endpoint>
                                    <address format="soap11"
                                            uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                                </endpoint>
                            </send>
                        </sequence>
                    </target>
                </iterate>
            </inSequence>
            <outSequence/>
        </target>
        <publishWSDL uri="file:samples/service-bus/resources/smooks/PlaceStockOrder.wsdl"/>
    </proxy>
</definitions>

1. Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000. Then add the plain text builder to the messageBuilders section of the axis2.xml found in the <EI_HOME>/conf directory. Here is the sample configuration.

<messageBuilder contentType="text/plain" class="org.apache.axis2.format.PlainTextBuilder"/>

2. Enable the vfs transport in axis2.xml by uncomenting the vfs transport sender and receiver configurations in the axis2.xml.

3. User has to edit the synapse_sample_654.xml found in the <EI_HOME>/samples/service-bus directory. These are the configuration parameters that needs to be edited.

  • transport.vfs.FileURI
  • transport.vfs.MoveAfterProcess
  • transport.vfs.ActionAfterFailure

4. Start the ESB profile with the sample 654 configuration (i.e. wso2esb-samples.sh -sn 654).

5. Drop the edi.txt file found in the <EI_HOME>/samples/service-bus/resources/smooks directory to the transport.vfs.FileURI parameter specified directory.