Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation :
repository/samples/directory that includes all Integration profile samples is changed to
repository/samples/resources/directory that includes all artifacts related to the Integration profile samples is changed to
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.
To build the sample:
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>/confdirectory) as shown below.
- Enable the vfs transport in the
axis2.xml file by uncommenting the vfs transport sender and receiver configurations as shown below.
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.xmlfile found in the
<EI_HOME>/samples/service-busdirectory) 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:
Executing the sample
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/smooksdirectory. Copy this
edi.txtfile to the folder you specified for the
transport.vfs.FileURIparameter in the sample configuration.
Analyzing the output
The Smooks mediator will first translate the EDI message into XML as shown below.
The XML shown above will then be transformed into the following format after XSLT translation:
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: