Using Before/After PUT-GET commands in BizTalk 2004 FTP adapter


BizTalk 2004 FTP adapter allows administrators to specify Before/After PUT (or GET) commands. This is usually helpful to change the default directory after the initial FTP login.

 
Some folks have tried FTP commands like cd dirname without success. It fails with “unknown command“. The reason for this is that cd is an FTP client command and not a raw FTP command (i.e. FTP protocol command). Most (if not all) FTP client provide a command translation interface to make the FTP protocol “look” similar to regular shell commands. For instance, under UN*X, cd is translated to CWD and ls is translated to LIST.
 
You have to use FTP protocol commands. Here is a non exhaustive list of the command you can use with the FTP adapter in BizTalk 2004 (I pulled it from the RFC at http://www.faqs.org/rfcs/rfc959.html). The striked lines are commands that you do nto want to use (see below).
 
APPE – append to a remote file
CDUP – CWD to the parent of the current directory
CWD  – change working directory
DELE – delete a remote file
LIST – list remote files
MDTM – return the modification time of a file
MKD  – make a remote directory
MODE – set the transfer mode
PASS – send password
PASV – enter passive mode
PORT – open a data port
PWD  – print working directory
QUIT – terminate the connection
RETR – retrieve a remote file
RMD  – remove a remote directory
RNFR – rename from
RNTO – rename to
SITE – site-specific commands
SIZE – return the size of a file
STOR – store a file on the remote host
TYPE – set the transfer type
USER – send username

Update [July 6th, 2004]: I introduced by mistakes commands that cannot be executed as part of a “Pre“ and/or “Post” FTP command. For instance, consider QUIT. This command, when executed as a “Pre“ command will shut down the session, making it impossible for the adapter to actually get or put a file. Moreover, STOR, cannot be used because it requires an actual file to be transfered. This is the job of the “PUT” operation in BizTalk. So intead of using STOR in a Pre/Post command, you should use the FTP adapter’s main feature which is to tore or get files.

Comments (3)

  1. Patrick Wellink says:

    Is there a way to detect if a file is readonly on the FTP Server ?

    I would like something lke…..

    See if a file Exists If so delete it, if the delete fails we don’t have enough permissions and we can throw a kind of permission error in teh orchestration….

    Is this possible

  2. Gilles says:

    Patrick: To the best of my knowledge, the FTP adapter does not directly allow you to "test" is a file is there or not and take action if it is.

    You could define a server side command that performs this and execute it using QUOTE SITE xxx or QUOTE RCMD xxx. Some servers require you to be logged as admin to run SITE commands, others allow you to configure this.

    I am not an FT transport expert, so if anybody has a better idea, I would love to hear it.