Wednesday, January 29, 2020

How to List, Read, ZIP, Write Files in OIC

How to List, Read, ZIP, Write Files in OIC

In this example, we are going to see how to use the FTP adapters to List, Read, ZIP and write files.
Below is the Overview of our exercise,
  • Create a Connection
  • Create Integration
    • List Files (Using FTP Adapter)
    • For Each File Present in that Location,
      • Download the File (Using FTP Adapter)
      • ZIP the File (Using Stage Activity)
      • Write the File (Using FTP Adapter)

Create Connection

Please check my earlier post for step by step instruction on creating connection for FTP Adapter.

Create Integration

Create a App Driven Orchestration.


Create the SOAP Adapter as a start.



Drag and drop the FTP Connection from Invokes.


We are going to use this FTP adapter for listing the files present in remote location. Name it as ListFiles and click next


Select Operation as ListFiles
Provide Input directory and File Name pattern. You can override this in run-time using map activity.
Click Next and Done.


Now we are going to read each file and ZIP it and produce it to a new FTP Location.
Drag and Drop ForEach activity from Actions tab.

 Edit the For Each Activity.

Provide name and repeating element details. And decide the current element name(it can be anything but provide a relevant name)

Drag and Drop the FTP adapter once more, this time we are going to download the file to local for us to ZIP the File.


Provide the Input directory of remote FTP Location, and Download Directory of something unique.
OIC will create the Folder in run-time locally and download the file to this location.
*File Name will be overridden in run-time using map activity.

 Edit the Map Activity to provide the Directory and File Name to be downloaded. it will be fetched from Current element name which was given in For-Each.
Note: Also you can see i have overridden the Download Directory as well. Since there will be more files in remote location i want each file to be download to new location. If you want all the files to be downloaded to the same folder, don't assign anything here.


Now you have the files downloaded to OIC, you can ZIP that directory using Stage File Activity.



Specify the File Name : Target file name (.zip file)
Specify the Directory to ZIP : Provide the Directory name where the File was downloaded(previous step)
Specify the Output Directory: Mention unique Directory name (its local to OIC)


Now we have Downloaded and Zipped the file in a OIC location. We have to use FTP adapter again to write this file to remote server. So drag and drop FTP Adapter and Configure it.




Now Click on the Edit Map to Override the Filename and File.



And You are Done.!!! 
Create a SOAP UI Project to trigger the Integration.

No comments:

Post a Comment