· 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?

Discussion (4)0
Log in or sign up to continue

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.


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:
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?