0
votes

Hi i am working on wso2 ESB 4.7.0,

I wish to process the any particular file like .txt,.xls,.xml , my client provide the data in above format files in system folder,i need to pick from there and process that file , i wish to store that data into data base. Sample .txt file is

ename intime outtime eid 
-------------------------
john  9.10   6.10    y001
scott 10.00  7.00    yoo2
tiger 9.00   6.00    y003

above data i need to insert in empdetails table. I tried with VFS transport in WSO2 ESB, it is able to write the data into text file but how to read from data into a text file.

Help me to solve this.

1

1 Answers

2
votes

I understand that you want to read data from a file

To do that, you just need to declare a VFS proxy :

<proxy xmlns="http://ws.apache.org/ns/synapse" name="IncomingFile" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
   <target inSequence="YourSequence" />
   <parameter name="transport.PollInterval">15</parameter>
   <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
   <parameter name="transport.vfs.FileURI">file:///Your_directory</parameter>
   <parameter name="transport.vfs.MoveAfterProcess">file:///Your_directory_OK</parameter>
   <parameter name="transport.vfs.MoveAfterFailure">file:///Your_directory_KOKO</parameter>
   <parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
   <parameter name="transport.vfs.ContentType">text/plain; charset=ISO-8859-1</parameter>
   <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
</proxy>

Don't forget to enable VFS transport receiver in you repository/conf/axis2/axis2.xml :

<transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/>

The message builder associated with text/plain in your axis2 conf will be used to build the message (org.apache.axis2.format.PlainTextBuilder by default : text content will be encapsulated into an xml node)

You may want to develop and use your own message builder, in order to transform the particular file format into a specific xml tree in order to use XPath inside your mediation.

An alternative would be to use smooks.