Friday, April 7, 2017

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

This blog illustrates on how to use  File Connector Version 2 with WSO2 ESB 4.9.0/5.0.0. In here we are reading a simple text file using file connector.

Download the File Connector Version 2 from here.
Download ESB from here.

In this example, we will be using WSO2 ESB 4.9.0 with file connector version 2.0.7. In order to install the file connector you are required to start the ESB instance using below command: (<ESB_HOME>/bin)
 ./wso2server.sh

To add a connector:

  • On the Main tab in the ESB Management Console, under Connectors click Add.
  • Click Browse, specify the ZIP file, and click Open.
  • Click Upload.
  • The connector will now appear in the Connectors list and is ready to be enabled in your ESB instance.

To enable a connector:

  • On the Main tab in the ESB Management Console, under Connectors click List to view the uploaded connectors.
  • Click Enable next to a connector you want to enable, and then confirm that you want to change its status. 

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-07 14:26:50,898]  INFO - LogMediator To: /services/Proxy1, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:f7270bb4-5935-4bca-828b-c5ad7f8fc9bb, 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>

1 comment:

  1. Casinos Near Me - The JamBase Casino
    Find your perfect 광양 출장안마 spot 밀양 출장안마 for entertainment, dining, shopping and 원주 출장마사지 more. 목포 출장마사지 All your favorite 안성 출장샵 slots, video poker, blackjack, roulette, keno and more at our casino

    ReplyDelete