Switching from FTP Listener to Mail Sender

This example demonstrates how WSO2 Micro Integrator receives messages through the FTP transport listener and forwards the messages through the mail transport sender.

VFS transport listener will pick the file from the directory in the FTP server. The file in the FTP directory will be deleted. The response will be sent to the given e-mail address.

Synapse configuration

Following are the integration artifacts that we can used to implement this scenario. See the instructions on how to build and run this example.

<proxy name="SFTPtoMailToProxy" startOnLoad="true" transports="vfs" xmlns="http://ws.apache.org/ns/synapse">
    <parameter name="transport.vfs.FileURI">vfs:sftp://guest:guest@localhost/test?vfs.passive=true</parameter> <!--CHANGE-->
    <parameter name="transport.vfs.ContentType">text/xml</parameter>
    <parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
    <parameter name="transport.PollInterval">15</parameter>
            <header name="Action" value="urn:getQuote"/>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            <property action="set" name="OUT_ONLY" value="true"/>
                    <address uri="mailto:user@host"/>
    <publishWSDL key="conf:custom/sample_proxy_1.wsdl" preservePolicy="true"/>

Build and Run

Create the artifacts:

  1. Set up WSO2 Integration Studio.
  2. Create an integration project with an ESB Configs module and an Composite Exporter.
  3. Add sample_proxy_1.wsdl as a registry resource (change the registry path of the proxy accordingly).
  4. Create the proxy service with the VFS configurations parameters given above.
  5. Configure MailTo transport sender.
  6. Deploy the artifacts in your Micro Integrator and start the Micro Integrator.

Set up the back-end service.

  1. Download the back-end service
  2. Extract the downloaded zip file.
  3. Open a terminal, navigate to the axis2Server/bin/ directory inside the extracted folder.
  4. Execute the following command to start the axis2server with the SimpleStockQuote back-end service:

    sh axis2server.sh

Add the following request.xml file to the sftp location and verify the content received via the mailto transport.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <m0:getQuote xmlns:m0="http://services.samples">