Search code examples
wso2wso2-esbwso2-enterprise-integrator

How do I transfer files from server to server using wso2 vfs?


I have created a wso2 file transfer service which transfers files from one folder to another on my local machine, this is done using a proxy and a sequence on integration studio, I then export a carbon application and deploy it on enterprise integrator. However, the moment I try to transfer files from server to server or from folder to folder within the same server the files do not transfer even though there are no errors in the error log. I have created my own FTP server using iis. I have also encoded the FTP file path. Please see my proxy and sequence below, any help will be greatly appreciated.

Proxy service,

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="YenloProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <log level="custom">
                <property name="sequence" value="Proxy"/>
            </log>
            <clone>
                <target sequence="YenloSequence"/>
            </clone>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </target>
    <parameter name="transport.PollInterval">15</parameter>
    <parameter name="transport.vfs.FileURI">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FIncoming%2F</parameter>
    <parameter name="transport.vfs.ContentType">text/plain</parameter>
    <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
    <parameter name="transport.vfs.MoveAfterFailure">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FFailure%2F</parameter>
    <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
    <parameter name="transport.vfs.FileNamePattern">.*.dat</parameter>
    <parameter name="transport.vfs.MoveAfterProcess">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FOutgoing%2F</parameter>
</proxy>

Sequence,

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="YenloSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <log level="custom">
        <property name="sequence" value="YenloSequence"/>
    </log>
    <property expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/>
    <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
    <property name="ClientApiNonBlocking" scope="axis2" type="STRING" value="true"/>
    <send>
        <endpoint name="FileEpr">
            <address uri="vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FOutput%2F">
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>1</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </address>
        </endpoint>
    </send>
</sequence>

Solution

  • In the proxy service, the transports attribute is used to define the transport protocols that are used to receive messages. Since we are using VFS Transport to receive the file, you need to set the value of the transport as follows, transports="vfs". You may refer to this example for more information.