Wednesday, April 12, 2017

Configuring WSO2 ESB 4.8.1 with File Connector Version 2 to read a text file

Please note that File connector Version 2 is not supported with WSO2 ESB 4.8.1. To make the file connector V2 to be supported with ESB 4.8.1 you are required to upgrade the commons-net orbit bundle in ESB 4.8.1.

All you need to do is to get a copy of the commons-net_3.3.0.wso2v1.jar from a ESB 4.9.0 pack which could be found on <ESB_4.9.0_HOME>/repository/components/plugins and apply it to <ESB_4.8.1_HOME>/repository/components/dropins. 

Restart the ESB 4.8.1 server after applying the commons-net_3.3.0.wso2v1.jar.

Please follow below steps in order to read a text file using file connector V2 in ESB 4.8.1. 

Upload the file connector V2 and enable it. 
Create a file and add a text value to it. Here we added below text value to the text file.
 hello Shadsha 
Create a pass-through proxy service in ESB. Please find the proxy configuration below: (As the source path specify the path to the above created text file)
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="testProxy"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <fileconnector.read>
            <source>/home/ubuntu/Desktop/file/file1.txt</source>
            <contentType>text/plain</contentType>
            <encoding>utf-16le</encoding>
         </fileconnector.read>
         <log level="full"/>
         <respond/>
      </inSequence>
   </target>
</proxy>

Send a request to the proxy service and you will be able to see the logs as below:
[2017-04-11 16:30:37,677]  INFO - LogMediator To: /services/Proxy1, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:6680285b-32e6-4d23-887f-22b65f5ea002, 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">hello Shadsha</text></soapenv:Body></soapenv:Envelope>

No comments:

Post a Comment