...
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 details to the back-end service.
Prerequisites
...
Deploy the back-end service (SimpleStockQuoteService) in the Axis2 server. For instructions on deploying sample back-end services, see Deploying sample back-end services.
- Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
Enable the plain text message builder in the
axis2.
xml file (found in the<EI_HOME>/conf
directory) as shown below.Code Block language html/xml <messageBuilder contentType="text/plain" class="org.apache.axis2.format.PlainTextBuilder"/>
- Enable the vfs transport in the
axis2.
xml file by uncommenting the vfs transport sender and receiver configurations as shown below.Code Block <transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/> <transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/>
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.
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:
Code Block <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
Now you need to add a text file with an EDI message to the folder you specified for the transport.vfs.FileURI
parameter in the sample configuration and run the sample. WSO2 EI is shipped with a sample text file with an EDI message: This is the edi.txt file stored in the <EI_HOME>/samples/service-bus/resources/smooks
directory.
...
Follow the steps given below.
- 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." - 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 thisedi.txt
file to the folder you specified for thetransport.vfs.FileURI
parameter in the sample configuration.
Analyzing the output
The Smooks mediator will first translate the EDI message into XML as shown below.
...