Working With the FTP Target Connector

This section discusses working with the FTP target connector.

The FTP target connector enables the gateway to use FTP to send messages to and receive messages from FTP servers. It uses the PUT command to place messages or files from the integration gateway onto remote FTP servers. The GET command is used to receive messages from FTP servers. Outbound messages through the FTP target connector are UTF-8 encoded.

PeopleSoft Integration Broker also supports secure communication with FTP servers using FTPS.

Note: The FTP target connector handles string-based data only. Binary data is not natively supported in PeopleSoft Integration Broker.

The connector ID for the FTP target connector is FTPTARGET.

In addition to specifying Java Archive (JAR) files in the web server CLASSPATH and setting node-level connector properties, to use this connector you must also specify the integration gateway URL in the Gateways component.

Information about specifying the required JAR files and setting node-level FTP and FTPS connector properties is discussed in this section.

See Specifying Required JAR Files, Setting Node-Level FTP Connector Properties, Setting Node-Level FTPS Connector Properties.

Information about specifying the integration gateway URL is discussed elsewhere in the product documentation.

See Administering Integration Gateways.

If using an IIS FTP server with the FTP target connector, ensure the directory listing style in IIS is configured with type as UNIX and not as MS-DOS.

For the FTP target connector to function properly the following JAR files from IBM must reside in the CLASSPATH of the web server running the integration gateway:

  • FTPProtocol.jar

  • ipworksssl.jar (required for FTPS)

This section describes the required node-level properties you must set to use the FTP target connector.

The following table describes the required node-level connector properties:

Property ID

Property Name

Description

HEADER

SendUncompressed

Specify whether to send messages decompressed. Values are:

  • Y: Send messages decompressed and decoded. This is the default value.

  • N: Send messages compressed and base64 encoded.

FTPTARGET

FTPMODE

Specify whether to use an active or passive FTP connection for integrations. The valid values are:

  • ACTIVE. (Default.) Use an active FTP connection.

  • PASSIVE Use a passive FTP connection.

FTPTARGET

HOSTNAME

Specify the IP address or name of the FTP server for the connection.

FTPTARGET

METHOD

Specify the method to send or receive messages. The valid values are:

  • PUT (default). Send messages to an FTP server.

  • GET. Retrieve messages from an FTP server.

  • GETDIRLIST. Retrieve a directory list of files from an FTP server.

FTPTARGET

DIRECTORY

Specify the remote directory into which the file is placed.

Note: When using the GET method you must specify the location where the file resides for the method to function properly.

If not specified, the default directory of the FTP server on the remote site is used.

FTPTARGET

FILENAME

(Optional.) Specify the name of the file saved on the recipient's FTP server. By default, the file name is a concatenation of the following:

  • Originating node name.

  • Originating username.

  • Operation name.

  • Originating timestamp.

  • Segment ID.

If you do not specify a filename, the FTP(S) target connector performs a GET to retrieve the directory list from the remote FTP server. See the section on Directory List Support earlier in this section.

FTPTARGET

USERNAME

Enter the FTP server login ID.

FTPTARGET

PASSWORD

Enter the password for the login to the FTP server.

This password must be encrypted.

See Encrypting Passwords.

FTPTARGET

TIMEOUT

Specify the time in milliseconds for the connector to wait for the message to transmit. If the timeout period expires without a successful transmission, the transaction fails.

The default value is 50000 (50 seconds).

FTPTARGET

TYPE

Indicates the FTP mode used to transfer the file. The valid options are:

  • ASCII (default)

  • BINARY

When you select ASCII, all characters are converted to their ASCII equivalents. When you select BINARY, data is copied bit-by-bit and no conversion is performed.

The following table describes properties to use for secure FTPS communication.

Property ID

Property Name

Description

FTPTARGET

FTPS

Enables secure communication over FTP. Values are:

  • Y: Enable FTPS communication.

  • N: Disable FTPS communication. This is the default value.

FTPTARGET

CLIENTCERT

(Optional.) To use client authentication when establishing a connection with the target or receiving system, enable the CLIENTCERT property.

FTPTARGET

PORT

Specify the port used for communication. The default port is 21.

FTPTARGET

SSLSTARTMODE

(Optional). Use this property to set the SSL start mode. Values are:

  • DEFAULT.

    If the remote port is set to the standard plain text port of the protocol (where applicable), it will behave the same as if SSLSTARTMODE is set to sslExplicit . In all other cases, SSL negotiation will be implicit (sslImplicit).

  • IMPLICIT.

    The SSL negotiation will start immediately after the connection is established.

  • EXPLICIT.

    The connector first connects in plain text, and then explicitly starts SSL negotiation through a protocol command such as STARTTLS.

One of the optional node-level FTP connector properties is FILENAME. If you do not know the file name of the file you would like to receive but do not know the directory in which it resides, you can use the GETDIRLIST method to retrieve a directory list. The directory list is retrieved in XML format and you must parse the XMLDocument to read its contents. You can then use the GET method to get the actual file. The following example shows the format of a returned directory list.

<DirList>
   <File name="sample.bat">
      <Date></Date>
      <Size>1234</Size>
      <Time></Time>
      <isFile>True</isFile>
   </File>
   <File name="sample2.bat">
      <Date></Date>
      <Size>1234</Size>
      <Time></Time>
      <isFile>True</isFile>
   </File>
   <File name="temp">
      <Date></Date>
      <Size>1234</Size>
      <Time></Time>
      <isFile>False</isFile>
   </File>	
</DirList>	


Date : Date on the file on remote system
Time : Time on the file on remote system
Size : Size of the file
isFile : True if it is a file. False if it is a directory.

The following example shows the code needed to use the FTP connector to get a list of the files in a directory, run through the list of files, select a file, and retrieve it. To use this example, you must know the directory in which the file resides.

If you know the name of the file you wish to receive but do not know the directory, use the FILENAME property and the GETDIRLIST method to retrieve a directory list, as described previously in this section.

See Using Directory Lists.

Local XmlDoc &Output;
Local Message &MSG1, &MSG2, &MSG3;

&MSG = CreateMessage(OPERATION.QE_FLIGHTPLAN_UNSTRUCT);

/* Set ConnectorName and Connector ClassName */
&MSG.IBInfo.IBConnectorInfo.ConnectorName = "FTPTARGET";
&MSG.IBInfo.IBConnectorInfo.ConnectorClassName = "FTPTargetConnector";

/* Set the FTP connector properties in the ConnectorInfo */
/* Method name can be either Get or GetDirlist.  */
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("METHOD", 
     "GET",%Property);
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("HOSTNAME", 
     "ftp.example.com",%Property);
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("USERNAME", 
      "sam",%Property);

/*  Encrypt the password */
&pscipher = CreateJavaObject("com.peoplesoft.pt.integrationgateway.common.
     EncryptPassword");
&encPassword= &pscipher.encryptPassword("ftpserverpassword");
 &pscipher = Null;

&string_return_value = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties
     ("PASSWORD", encPassword,%Property,);
&string_return_value = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties
     ("DIRECTORY", "/incoming/tmp",);

/* Do Connector Request */
&MSG2 = %IntBroker.ConnectorRequest(&MSG);

/* Get XMLDoc from MSG2*/
&fileListXmlDoc = &MSG2.GetXmlDoc();

/*Parse the XMLDoc. Structure of the DirList Message is 
<DirList>
     <File name="sample.bat">
        <Date></Date>
        <Size>1234</Size>
        <Time></Time>
        <isFile>True/False</isFile>
     </File>
</DirList>*/

&XmlNode = &fileListXmlDoc.DocumentElement.FindNode("/DirList/File");

/* Get the file name */
&attName = &XmlNode.GetAttributeName(1);
&fileName = &XmlNode.GetAttributeValue(&attName);

/* Get the file name from the Remote FTPServer */
&MSG = CreateMessage(OPERATION.QE_FLIGHTPLAN_UNSTRUCT);

/* Set ConnectorName and Connector ClassName */
&MSG.IBInfo.IBConnectorInfo.ConnectorName = "FTPTARGET";
&MSG.IBInfo.IBConnectorInfo.ConnectorClassName = "FTPTargetConnector";

/* Set the FTP connector properties in the ConnectorInfo */
/* Mehtod name can be either Get */
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("METHOD", 
   "GET",%Property);
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("FILENAME", 
     &fileName,%Property);
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("HOSTNAME", 
     "ftp.example.com",%Property);
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("USERNAME", 
   "sam",%Property);

/*  Encrypt the password */
&pscipher = CreateJavaObject("com.peoplesoft.pt.integrationgateway.common.
     EncryptPassword");
&encPassword= &pscipher.encryptPassword("ftpserverpassword");
 &pscipher = Null;

&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("PASSWORD", 
     encPassword,%Property,);
&nRet = &MSG.IBinfo.IBConnectorInfo.AddConnectorProperties("DIRECTORY", 
   "/incoming/tmp",);

/* Do Connector Request */
&MSG3 = %IntBroker.ConnectorRequest(&MSG);