Question
Gevorg Arutiunian · Apr 22, 2020

FTP adapter

Hi community,

I am now working with an ftp adapter. I have no problem connecting to the FTP server, but there are problems with interacting with files. Has anyone had any experience with an FTP adapter, such as getting/modifying/deleting files?

 

10
0 4 216 1

Replies

Hi Gevorg,

From what I read, it looks like you need to use EnsLib.FTP.OutboundAdapter. The class where you would specify the Adapter parameter will be a version of EnsLib.FTP.PassthroughOperation. You can use this class as an example. To create your outbound custom Operation, extend Ens.BusinessOperation. Once you specify the Adapter, you can call its methods within the OnMessage() method. From your use case, it looks like you can use these methods:

- NameList(): get a list of files on FTP server

- GetStream(): retrieve a named file from FTP server

- Delete(): delete a named file from FTP server.

There are other methods available. Please read the "Using the FTP Outbound Adapter" chapter in the "Using FTP Adapters with Ensemble" book - it is excellent and will probably give you all you need.

Hi Vitaly,

I need to use a business service to retrieve txt files from the FTP server and send further processing to the business process.As I understand it, here I need to create a class extend from EnsLib.FTP.PassthroughService and already work with it, but I can not get information about the files.

Gevorg,

When I was researching this, I also went first to the methods on Enslib.FTP.InboundAdapter and the settings on EnsLib.FTP.PassthroughService (as they include FTP Server and FTP Port). But reading this again, I think that this Business Service (like all Ensemble Business Services) behaves like a daemon - that is, it sleeps until a connection from a sender wakes it and starts sending data. I think the FTP Server settings are there so that the Service can output a response.

In order to get a file or files into the Business Service, you may need something else to actually run ftp commands on the server. We had accomplished that by creating a shell script that would connect to the server, get the daily batch and then process them with a regular Enslib.File.PassthroughService. I also found the following onlne:

https://community.intersystems.com/post/how-customize-ensemble-settings
https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GNET_ftp
The 1st article talks about how to customize FTPInboundAdapter (though for a different use case), and the 2nd one how to use Cache FTP tools. Combining the information may get you where you need to be.

Or, I think you could use the tools for FTP.OutboundAdapter, retrieve your files into a Business Operation and send them back to a Business Process for processing...

Good luck!

Hi Gevorg,

I had recently encountered a use case like yours where we needed to connect to an FTP server and retrieve files from it. We tried to used EnsLib.FTP.PassthroughService but found it impractical. The service performance was very slow and we would wait minute before the file was actually picked up. We ended up running a shell script that would connect to the FTP server, mget all of the files and copy them to a local directory where EnsLibFile.PassthroughService would take care of them.

I wonder whether you were able to resolve your problem with FTP?