Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Appendix B FTP Script Examples : First Tutorial Example

First Tutorial Example
The putexample.txt script puts the document on the FTP server. The mgetexample.txt script does an mget from the FTP server of all files that match a particular search filter, which in this example is the trading host name.
How putexample.txt Works
This script gets the FTPClient object from the job variable that is created at runtime by BusinessConnect. The FTPClient object is used to connect to the FTP server. (This works only in non-proxy mode.) It checks if the examples/BC directory is available. If it is, it puts the file created by the Initiator's outbound process. If the examples/BC directory is not present, that directory is created before the file is actually stored in the FTP server.
If there are connection failures, a flag called retryScripts is set to true and passed on to TIBCO BusinessConnect to retry the execution when retry of the outbound process occurs.
How mgetexample.txt Works
This script gets the FTPClient object from the job variable that is created at runtime by TIBCO BusinessConnect. FTPClient object is used to connect to the FTP server. It checks if the examples/BC directory is available. If it is, the script calls executeMgetCmd to get all the files from the FTP Server.
Once the files are successfully retrieved, the examples/BC directory is deleted. If the files could not be retrieved for some reason, for example, if a put is happening at the same time and the file descriptor is being locked by another process, then the examples/BC directory is not removed.
Tutorial Files
The following files are part of this tutorial:
BC_HOME\samples\bc\ftpscripts\putexample.txt
BC_HOME\samples\bc\ftpscripts\mgetexample.txt
These are both EcmaScript files.
How to Send Files
To send a document using BusinessWorks process, see File Pollers.
Setting Up the First Tutorial
Steps to Perform on the Initiator Computer
The following steps must be performed on the Initiator computer:
1.
2.
For the participant Seller, click the Transports tab for the EZComm protocol.
3.
Click Add.
4.
5.
Select FTP in the Type list.
6.
7.
See TIBCO BusinessConnect Trading Partner Administration Guide, FTP/S Outbound for details.
8.
Select Script in the File Processing list.
9.
Click change in the Scripts area.
10.
Select Uploaded File from the Type list.
11.
Click Browse to navigate to the BC_HOME\samples\bc\ftpscripts directory.
12.
Select the putexample.txt file and then click Open.
13.
14.
Click Save.
15.
Click TIBCO BusinessConnect > BusinessAgreements > Buyer-Seller.
16.
Click EZComm in the Agreement Protocol Binding list.
17.
Click the Transports tab.
18.
Select FTP from the Primary Transport list.
19.
Click Save twice.
Steps to Perform on the Responder Computer
The following steps must be performed on the Responder computer:
1.
2.
Click TIBCO BusinessConnect > BusinessAgreements > Buyer-Seller.
3.
Click the EZComm protocol binding.
4.
Click the Transports tab.
5.
Click Edit FTP Settings in the Inbound Transports for Partner ’Buyer’ area.
6.
Configure FTP. If you need help, see TIBCO BusinessConnect Trading Partner Administration Guide, Select and Configure FTP/S Inbound.
7.
Select Script in the File Processing list.
8.
Click change in the Scripts field.
9.
Select Uploaded File from the Type list.
10.
Click Browse to navigate to the BC_HOME\samples\bc\ftpscripts directory.
11.
Select the mgetexample.txt file. Click Open.
12.
13.
Select the Delete File check box.
14.
Click Save twice.
Running the First Tutorial Example
To run the first tutorial example:
1.
2.
To configure TIBCO BusinessConnect to poll a directory:
a.
b.
Specify Seller for the TpName directory. If your base directory is BaseDir, the directory path should be BaseDir/Seller.
c.
In TIBCO Administrator, click Application Management > BusinessConnect > Configuration.
d.
Click the BusinessConnect link.
e.
Click the Private Process Configuration tab.
f.
Click the EZComm link in the Outbound File Poller Configuration section.
g.
Select the Enable check box.
h.
Type BaseDir/Seller/*.* in the Directory to Monitor field.
i.
Click Save twice.
j.
Click Deploy.
k.
l.
3.
Copy the BC_HOME\protocols\ezcomm\samples\sampleXML\ WidgetAvailable.xml file into BaseDir/Seller.
Expected Results
After the Initiator BusinessConnect receives the file from the TIBCO ActiveMatrix BusinessWorks process or picks up the file from the outbound file poller directory, the following situations happen:
BusinessConnect then invokes the putexample.txt script. The script looks for the directory examples/BC in the FTP root directory and creates them if they do not exist.
On the Responder, BusinessConnect polls the directory specified in the inbound FTP configuration in the business agreement. When a file is detected, BusinessConnect runs the mgetexample.txt script, which looks for all the files in the examples/BC directory.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved