Using FTP to Put and Get Files

This sample service invokes the FTP put and get commands. The service reads a file and places it on the specified FTP server. The FTP get command is issued after a short pause and the file contents are written back to the local storage.



Prerequisites

Copy the ftp_put_file.log file included in this sample to the c:\tmp directory. If the directory is not available, see the steps listed in the Understanding the Configuration section.

Ensure that the following FTP server information is available:

  • FTP server name or IP address
  • FTP server port (default is 21)
  • FTP username
  • FTP user password

Procedure

  1. In the samples directory, select palette > ftp > PutAndGet and double-click tibco.bw.sample.palette.ftp.PutAndGet. For more information, see Accessing Samples .
  2. In Project Explorer expand the tibco.bw.sample.palette.ftp.PutAndGet project.
  3. Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
  4. Copy the ftp_put_file.log file to c:\tmp.
  5. Fully expand the Resources directory and then double-click FTPConnectionResource.ftpResource. Specify valid values for your FTP connection in the Host, Port, User Name, and Password fields. Click Test Connection to verify your FTP connection.


  6. Click File > Save.
  7. Fully expand the Processes directory and double-click FTP_Put_and_Get.bwp.
  8. Click Run > Debug Configurations.
  9. At left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  10. Click theApplications tab and then click the Deselect All button if you have multiple applications. Select the check box next to tibco.bw.sample.palette.ftp.PutAndGet.application.
  11. Click Debug.
    This runs the sample in Debug mode.
  12. Monitor the log/trace and after a minute, verify whether the PutAndGet.log file has been created at c:\tmp\PutAndGet.
  13. Click the Terminate icon to stop the process.

Result

  • The file specified by the module property BW_ftp_put_file is copied to the FTP server.
  • The file specified by the module property BW_ftp_get_file is written to c:\tmp\PutAndGet by the FTP server. The default name is PutAndGet.log.

Understanding the Configuration

The sample project has default values for the file names. You can change the defaults, if needed for your environment.

  1. Under Module Descriptors, click the configuration file.
  2. Modify BW_ftp_put_file to point to the input file.
  3. Modify BW_ftp_get_file to point to the output file that is written to on disk.