This documentation is for WSO2 Enterprise Integrator version 6.1.1 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata

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


This sample demonstrates how the Smooks mediator in WSO2 EI is used to process an EDI message before sending it to the back-end service. In this demonstration, you will deploy a sample back-end service in the ESB profile of WSO2 EI, and then provide an EDI message as the input. The Smooks mediator configuration will then translate the EDI message to XML. The ESB sequence will further process the XML message, and the Iterate mediator will send the message to the back-end service.


For a list of prerequisites, see Prerequisites to Start Samples.

Building the sample

Here is the sample with Smooks mediator.

<definitions xmlns="">
    <localEntry key="transform-xslt-key"
    <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>
        <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>
        <parameter name="transport.vfs.MoveAfterProcess">file:///home/user/dev/test/smooks/original</parameter>
        <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>
                <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">
                            <header name="Action" value="urn:placeOrder"/>
                            <property action="set" name="OUT_ONLY" value="true"/>
                                    <address format="soap11"
        <publishWSDL uri="file:samples/service-bus/resources/smooks/PlaceStockOrder.wsdl"/>

To build the sample:

  1. Deploy the back-end service (SimpleStockQuoteService) in the Axis2 server. For instructions on deploying sample back-end services, see Deploying sample back-end services.

  2. Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
  3. Enable the plain text message builder in the axis2.xml file (found in the <EI_HOME>/conf directory) as shown below.

    <messageBuilder contentType="text/plain" class="org.apache.axis2.format.PlainTextBuilder"/>
  4. Enable the vfs transport in the axis2.xml file by uncommenting the vfs transport sender and receiver configurations as shown below.
    <transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/>
    <transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/>
  5. Create three folders on your computer for the following purposes:

    • To store the original text file with the EDI message.

    • To store the text file with the EDI message after the file has been successfully processed by the Smooks mediator.
    • To store the text file with the EDI message if the file processing fails.
  6. Update the sample configuration file (which is the synapse_sample_654.xml file found in the <EI_HOME>/samples/service-bus directory) with the paths to the folders created in the previous step. Listed below are the parameters you need to update:

    • transport.vfs.FileURI: This parameter specifies the path to the folder that stores the text file with the EDI message.
    • transport.vfs.MoveAfterProcess: This specifies the path to the folder that stores the same text file after it is successfully converted by the Smooks mediator.
    • transport.vfs.ActionAfterFailure: This specifies the path to the folder that stores the same text file if an error occurs during the processing.

    See the following example of the sample configuration:

    <parameter name="transport.vfs.FileURI">file:///home/user/test/in</parameter>
    <parameter name="transport.vfs.MoveAfterProcess">file:///home/user/test/original</parameter>
    <parameter name="transport.vfs.MoveAfterFailure">file:///home/user/test/original</parameter>

Executing the sample

Follow the steps given below.

  1. Start the ESB profile of WSO2 EI with the sample 654 configuration. For instructions on starting a sample configuration, see Starting a sample configuration.

    The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."

  2. Now you need to provide a text file with an EDI message. WSO2 EI is shipped with a sample file named edi.txt inside the <EI_HOME>/samples/service-bus/resources/smooks directory. Copy this edi.txt file to the folder you specified for the transport.vfs.FileURI parameter in the sample configuration.

Analyzing the output

The Smooks mediator will first translate the EDI message into XML as shown below.

 Original EDI message (edi.txt file)
ORD*50.00*500*IBM*REF 10053
ORD*18.00*500*MSFT*ref 20088398289
 EDI message translated to XML
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=""><soapenv:Body><orders>
		<comment>REF 10053</comment>
		<comment>ref 20088398289</comment>

The XML shown above will then be transformed into the following format after XSLT translation:

 XML message translated by XSLT
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=""><soapenv:Body><m0:placeOrder xmlns:m0="http://services.samples">

The XML message (after XSLT translation) is then sent to the back-end service (SimpleStockQuoteService) by the Iterate mediator. You can see how the contents of the above message (orders) are received by the SimpleStockQuoteService, by checking the logs in the Axis2 server's terminal:

Accepted order #12 for : 200 stocks of SUN at $ 85.0
Accepted order #13 for : 500 stocks of IBM at $ 50.0
Accepted order #11 for : 100 stocks of MSFT at $ 170.0
Accepted order #14 for : 100 stocks of IBM at $ 138.0
Accepted order #15 for : 500 stocks of MSFT at $ 18.0
  • No labels