1

I am doing a simple file read using WSO2 ESB File connection 2. I try to read a .OUT file from the given directory. It reads the first file (alphabetical order?) well but I have no idea which file is read. Is there a (transport?) property that gets populated when a file is read?

Here is my code in a proxy service

<fileconnector.read>
 <source>file:///D:/temp</source>
 <filePattern>.*\.OUT</filePattern>
 <contentType>text/plain</contentType>
</fileconnector.read>
<log level="full"/>

I get the following response

 INFO - LogMediator To: /services/SampleProxy.SampleProxyHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:f5737693-6a51-4044-9134-95cd61eaeaa4, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><text xmlns="http://ws.apache.org/commons/ns/payload">abc,123&#xd;qwe,456&#xd;</text></soapenv:Body></soapenv:Envelope>
Community
  • 1
  • 1
Shiv
  • 25
  • 7

3 Answers3

0

Give it a try like this. (Just a suggestion. I didn't try.)

<log level="custom">
    <property name="FileName" expression="$trp:FILE_NAME" />
</log>
Bee
  • 12,251
  • 11
  • 46
  • 73
  • yeah it seems to be related to file inbound/vfs, not file connector. – Bee Mar 14 '17 at 23:44
  • Hmm thanks. Is there any option, other than class mediator? Unfortunately file search is also not working for me, I have posted it here - http://stackoverflow.com/questions/42798837/wso2-esb-file-connector-2-search-returns-empty-response – Shiv Mar 15 '17 at 00:08
0

If you want to read a particular file, you can pass the full path as a value in source and you can skip the file pattern value.

<fileconnector.read>
 <source>file:///D:/temp/abc.OUT</source>
 <filePattern></filePattern>
 <contentType>text/plain</contentType>
</fileconnector.read>
  • Thanks, but I do not know the file name. I only know the pattern. My requirement is to read any *.OUT file that is present in the directory and return the file name and content. I have ten files and this proxy is reading a file but I do not know which file is read. – Shiv Mar 15 '17 at 19:38
  • In the read operation, when we are giving the pattern I think it will read a first child from the parent folder. I think using search operation, we can list all the files of given pattern and then we can pass the full file path to the read operation without a pattern, we have to do some additional things when extracting files path one by one from the response of the search operation. – Vivekananthan Sivanayagam Mar 15 '17 at 19:51
0

This is a valid requirement. We will consider this in our future release. Please use [1] to track the progress.

[1] https://wso2.org/jira/browse/ESBCONNECT-192

Malaka Silva
  • 142
  • 1
  • 8