Blog

Managed File Transfer and Network Solutions

How To Set Up An Automated AS2 File Transfer

Posted by John Carl Villanueva on Thu, Nov 26, 2015 @ 03:33 PM

Overview

Last time, we posted a quickstart guide to setting up an AS2 server. The example in that post featured a manual method for sending EDI messages. Because EDI transactions are best carried out automatically, we thought it would be a good idea to show you how to implement such transactions on the same solution we used in that post. 


Since this is more like a continuation of the previous article, I suggest you click the link above to gather some context. 

Ready? Let's get this ball rolling.  

There are many ways to automate AS2 file transfers on JSCAPE MFT Server. In this example, we're going to employ a Directory Monitor that captures file additions and a trigger that responds to the Directory Monitor File Add event type. 

A Directory Monitor allows you to capture events on your local directories. For instance, a directory monitor can detect when a file is added, when a file is deleted, or when a file undergoes changes. The monitor we're about to create will be monitoring a directory for any new file additions. 

This can be useful in cases wherein, as part of a business process process, an EDI document is placed into the monitored directory for transmission.

As soon as our server detects that a file has been added into the monitored directory, it will automatically grab that file and forward it to the designated trading partner through an AS2 connection.  

 

directory_file_add_for_as2_file_transfer.png

 

Creating the Directory Monitor

It's time to create the directory monitor in question. Go to the Directory Monitors menu and click the Add button. 

 

add_directory_monitor_automated_as2_file_transfer.png

 

Give the monitor a name, e.g. "For AS2 File Transfer to ABC Co". After, that, navigate to the directory and select it. After you do that, the Directory field will then be populated with the path to that directory (e.g. E:\for ABC Co)

Make sure the Monitor file add checkbox is ticked and then click OK. These settings will allow this directory monitor to fire a Directory Monitor File Added event once a newly added file is detected.

Note that the Monitor interval is set to 600 seconds. That means, the monitor will check the monitored directory every 600 seconds. You may adjust that value accordingly.

 

as2_file_transfer_directory_monitor_parameters.png

 

If you want that directory monitor to activate on a pre-set schedule, say, every 8:30 AM on the second day of each month or every night at 9:30 PM, you can also do that. Check out these posts later if you want to see how to implement those:

How To Get Your MFT Server To Email You About Last Night’s Download

How To Delete Old Files From Your Server

 

Let's proceed. 

After clicking OK, you should then see your newly created directory monitor in the Directory Monitors tab. 

 

as2_file_transfer_list_of_directory_monitors.png

 

Creating the trigger

We're now ready to create a trigger that would respond if a file is added to the monitored directory. 

Go to the Triggers menu and then click the Add button. 

 

as2_file_transfer_add_trigger.png

 

Give the trigger a name (e.g. "AS2 File Transfer To ABC Co") and then select the Directory Monitor File Added event type. 

Click Next to proceed. 

 

as2_trigger_directory_monitor_file_added.png

 

In a production environment, it's possible to have several directory monitors that throw the Directory Monitor File Added event type. To make this trigger act only on an event thrown by the directory monitor we created earlier, you can specify that monitor in the Trigger Conditions box like this:

MonitorName = "For AS2 File Transfer To ABC Co"

wherein, if you recall, that's the name we assigned to our directory monitor. 

MonitorName is just one of the many variables you can use in this context. To know which variables are available for a particular trigger, just click the Variables button found near the bottom-left of the screen. 

Click Next to proceed. 

 

as2_trigger_conditions.png

 

In the succeeding screen, click the Add button to add a new Trigger Action. This will tell JSCAPE MFT Server what action this trigger should carry out in response to the Directory Monitor File Added event. Because we want it to forward the newly added EDI document file to an existing AS2 trading partner, select the Trading Partner File Upload action from the drop-down list. Click OK

 

as2_trading_partner_file_upload.png

 

When the Trading Partner File Upload action parameters dialog appears, do the following:

 

1. Select the trading partner from the Partner drop-down list (in our case, that would be "ABC Company TP-AS2", which was defined in the previous article)


2. Enter the %File% variable (or click the Add Variable button and select File) into the Local File field. In this context, the %File% variable holds the complete path of the file that was added into the monitored directory. The variables supported by a particular trigger action depends on the trigger event used. To know which variables are supported, just click the Add Variable button. 

 

3. Click OK

 

as2_trading_partner_file_upload_trigger_parameters.png

 

As soon as you get back to the main screen, don't forget to click the Apply button to finalize the trigger creation process.

 

That's it. Hope you enjoyed our tutorial. For more tutorials like this or articles that discuss file transfer automation/network security topics, enter your email address into the box at the upper-right corner of this page and subscribe to this blog.  

Would you like to try this out yourself? Download the free, fully-functional evaluation edition of JSCAPE MFT Server now. 

 

Download Now

 

 

Topics: JSCAPE MFT Server, Managed File Transfer, Business Process Automation, Tutorials, AS2