Hi all in this post I will explain you how we can use WSO2 ESB to send files across network via SMB (Server Message Block) protocol.
WSO2 ESB has neat features like vfs and well equipped in many protocols including SMB. So in this post I will show you how to read a file and finally how to send it via VFS to an SMB Windows endpoint.
In order to VFS to work you need to enable VFS receivers and senders in axis2.xml. To do so navigate to <ESB_HOME>/repository/conf/axis2/axis2.xml and uncomment the following lines.
<transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/> <transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/>
After enabling VFS you can create a proxy service as follows.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="VFSSMB" transports="https http vfs" startOnLoad="true" trace="disable"> <description/> <target> <inSequence> <log> <property name="ADI FTP" value="'file transfer...'"/> </log> </inSequence> <outSequence/> <faultSequence/> </target> <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter> <parameter name="transport.PollInterval">5</parameter> <parameter name="transport.vfs.FileURI">vfs:smb://Administrator:wso2pass@192.168.28.79/smbshare/in</parameter> <parameter name="transport.vfs.MoveAfterProcess">vfs:smb://Administrator:wso2pass@192.168.28.79/smbshare/out</parameter> <parameter name="transport.vfs.FileNamePattern">.*\.txt</parameter> <parameter name="transport.vfs.ContentType">text/plain</parameter> <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter> <parameter name="transport.vfs.MaxRetryCount">3</parameter> </proxy>
Here the proxy service will Poll the source directory after the given interval and read files if there are any and move them to the destination directory.
0 comments:
Post a Comment