Create a SFTP polling service in the OSB

You can use the FTP transport of a proxyservice to poll a certain directory for files. Lets make a simple service which polls for a catalog.txt file on a SFTP server.

First create a proxyservice, PS_PollCatalogFileService for example. Select Messaging Service as Service Type on the general tab.

Check the Text option for the Message Request Type on the Messaging tab.

Leave the Message Response Type on None.
On the Transport Tab, set the Protocol to SFTP and the Endpoint URI to the ftp server on which you want to poll. Make sure the URI looks like ‘sftp://127.0.0.1/poll/catalog’. If your going to use FTP, use the FTP protocol and port 21 (default). We assume you have a running FTP server on the same machine as where the OSB is running.

On the SFTP Transport tab you can select the Authentication method to use for the SFTP server. In our case, we just use the Username Password option. Select here a Service Account which you can create where you select a simple static Username/Password combination. For the Post Read Action we want archive as we want to able to see which files where transfered.

Now it is time to deploy. Make sure your FTP server is running and is reachable from your OSB server…firewalls etc… Now drop a file in the polling directory ftp-root/poll/catalog. If you check the log, there is a good chance you will get an authentication error. This is because you will need to place a known_hosts file on the OSB server in the following directory: /OSB_DOMAIN/osb/transports/sftp/. The transports and sftp directory might not exist yet. If so, create them. The known_hosts file will contain the name, ip, algorithm and public key of the server which you want to make the SFTP connection with. It will have to look like this:

getafix,172.22.52.130   ssh-rsa   AAAAB3NzaC1yc2EAAAABIwAAAIEAtR+M3Z9HFxnKZTx66fZdnQqAHQcF1vQe1+EjJ/HWYtgAnqsn0hMJzqWMatb/u9yFwUpZBirjm3g2I9Qd8VocmeHwoGPhDGfQ5LQ/PPo3esE+CGwdnCOyRCktNHeuKxo4kiCCJ/bph5dRpghCQIvsQvRE3sks+XwQ7Wuswz8pv58=

See here for more details about the known_hosts file and SFTP transport. Once you have the known_hosts file in place, the proxyservice should do it’s thing and grab the file.

Leave a Reply

Your email address will not be published. Required fields are marked *

*