FTP

Use the IBM® App Connect Enterprise Toolkit to configure message flow nodes that have been converted from the IBM App Connect Professional FTP activities.

About this task

When you import an orchestration that contains FTP activities, the conversion utility creates a message flow with the FileRead, FileOutput, FileInput nodes, and JavaCompute nodes. See Table 1, for information on which nodes are used for each of the activities.

Table 1. IBM App Connect Professional FTP activities and the corresponding IBM App Connect Enterprise message flow nodes
IBM App Connect Professional activity IBM App Connect Enterprise node
Get file

FileRead node

Put file

FileOutput node

Rename file

FileRead node

FileOutput node

Delete file

FileRead node

List files

JavaCompute node

Poll directory

FileInput node

FileOutput node

Steps to connect FTP server

Procedure

  1. Select the FTP node:
    Open your message flow in IBM App Connect Enterprise and drag the appropriate FTP node (for example FileInput, FileOutput, File Read or FileExists) to your flow.
  2. Configure the FTP:
    In the properties tab, select the FTP tab
    1. Select the Remote Transfer checkbox
    2. Select SFTP from drop down in the transfer protocol propertyInterface for selecting remote file transfer properties. FTP is highlighted in Transfer protocol input box
  3. Set the FTP server connection:
    Server and port:
    • Enter the FTP server address and the port number, for example 9.20.192.15:21Interface for specifying server address and port number
  4. Security identity:
    Use this command to create securityidentity for all FTP nodes
    mqsisetdbparms -w workDir -n ftp::secId -u <userName> -p <password>
    For example:

    mqsisetdbparms -w C:\ACE12NODEWS\TEST_SERVER -n ftp::DUMMYFTP -u builduser-p builduser

    Replace:
    • workDir: the working directory of your integration server
    • secId: a name you define for the security identity
    • userName: the FTP server username
    • password: the FTP server password

    Here DUMMYFTP is the Server identity given in IBM App Connect Enterprise Console to run:App Connect Enterprise Console with server identity created

    Server Directory: specify the directory on the FTP server where the files are located (for File input node) or the directory where the files should be uploaded (for File Output node). For example: /incoming/ for reading files or /outgoing/ for writing files.

    FTP endpoint details screen:FTP endpoint screen showing all input boxes filled and properties specified

    Note: After running the command successfully, restart your integration server in IBM App Connect Enterprise to apply the changes. Right click on the integration server (for example: TEST_SERVER1 in the toolkit and select restart.Screenshot of context window listing options to interact with the integration server
  5. Use a third-party tool like FileZilla or WinSCP to test the FTP connection. Make sure to provide the FTP details (Host, Username, Password, and Port) and connect

FileRead node for get file activity

About this task

Files can be retrieved using the File Read node in IBM App Connect Enterprise

Procedure

  1. Set the input directory property to any local directory path. For example: C:\Users\Administrator\Desktop\FileReadNode
  2. Enter the file name or pattern to identify the files to process (for example, *.txt*, *.JSON*, for multiple files)
    The default action on successful processing is delete. To move the files instead of deleting them, select other options in the drop down Dropdown showing options for actions upon finishing. 'No action' is highlighted
  3. In the message domain parsing property, select message domain from the drop down to specify how the file content should be interpreted. For example, JSON: for java script object notation messages
    Screenshot of drop down listing options for message domain parsing. JSON: For Javascript Object Notation messages is highlighted
  4. Provide the FTP endpoint details under the FTP section in File Input node properties
  5. In the FTP tab, specify the server directory from which the files will be read. This directory should correspond to the location where the files are stored on the FTP server

Example

Example message flow:

HttpInput Node > File Read Node > HttpReply Node

FileOutput node for put file activity

About this task

Files can be written using the File Output node in IBM App Connect Enterprise

Procedure

  1. Set the directory property to any local directory path. For example, C:\Users\Administrator\Desktop\FileOutputNodeLocal
  2. Define the file name or pattern for generating the output file names ('*' for multiple files).
    Screenshot of input boxes for defining file output node properties
  3. Enter the FTP endpoint details under the FTP section in the FileOutput node properties
  4. In the FTP tab, specify the server directory where the files will be written. This directory is where the processed files will be saved on the FTP server.

Example

Example message flow:

FileInput Node > FileOutput Node

FileRead and FileOutput nodes for rename file activity

About this task

Follow these steps to rename a file in IBM App Connect Enterprise using the FileRead and FileOutput nodes

Procedure

  1. Set the Input directory property in the FileRead node to a local directory path, such as C:\Users\Administrator\Desktop\FileInputNodeLocal. Enter the new File name or pattern
  2. In the FileRead node properties, under the Basic tab, set the action to delete
    Interface to specify properties of the FileRead node
  3. Enter the FTP endpoint details under the FTP section in the FileRead node properties
  4. In the FTP tab of the File Read node, specify the server directory from which the files will be read. This is the directory on the FTP server where the processed files will be saved
  5. Set the directory property in the File Output node to a local directory path, such as C:\Users\Administrator\Desktop\FileOutputNodeLocal
    The FileOutput node writes the contents to a new file with the desired name (* for multiple files).Interface showing input boxes to specify File Output node properties
  6. Enter the FTP endpoint details under the FTP section in the File Output node properties
  7. In the FTP tab of the FileOutput node, specify the Server directory where the files will be written. This is the directory on the FTP server where the processed files will be saved.

Example

Example message flow:

HttpInput Node > FileRead Node > Fileoutput Node > HttpReply Node

FileRead node for delete file activity

About this task

Files can be deleted using the FileRead node in IBM App Connect Enterprise.

Procedure

  1. Set the Input directory property in the FileRead node to a local directory path, such as C:\Users\Administrator\Desktop
  2. Configure the File Read node to target a specific file. For example Employee.json.
  3. In the FileRead node properties, under the Basic tab, set the action to delete.
    Interface for specifying File Read node properties

    The file will be automatically deleted from the server after it is read successfully.

  4. Enter the FTP endpoint details under the FTP section in the FileRead node properties.
  5. In the FTP tab, specify the Server directory from which the files will be read. This directory should correspond to the location where your files are stored on the FTP server.

Example

Example message flow:

HttpInput Node > FileRead Node > HttpReply Node

JavaCompute node for list file activity

About this task

Java Compute Node code snippet that performs the following tasks:

Procedure

  1. Retrieve the list of files from an FTP server
  2. Access details of a file passed from the previous node in the flow using the LocalEnvironment
  3. Use hardcoded FTP connection details in the code
  4. Dependencies: add the Apache Commons Net library to your ACE environment:
    1. Add the commons-net-3.11.1.jar file to the ACE shared library
    IBM App Connect Enterprise environment interface. Commmons Net Library and shared library file path are highlighted

    If you are still facing issues with FTPClient in your Java Compute Node code, then add that jar in project build path.

    Interface showing jar files and class folders in the build path
  5. JavaCompute node:
    package com.ibm.acp.ace.ftp.example;
    
    import com.ibm.broker.javacompute.MbJavaComputeNode;
    
    import com.ibm.broker.plugin.MbElement;
    
    import com.ibm.broker.plugin.MbException;
    
    import com.ibm.broker.plugin.MbMessage;
    
    import com.ibm.broker.plugin.MbMessageAssembly;
    
    import com.ibm.broker.plugin.MbOutputTerminal;
    
    import com.ibm.broker.plugin.MbUserException;
    
    import org.apache.commons.net.ftp.FTPClient;
    
    import java.io.IOException;
    
    public class AcpToAceFileName extends MbJavaComputeNode {
    
        @Override
    
        public void evaluate(MbMessageAssembly inAssembly) throws MbException {
    
            MbOutputTerminal out = getOutputTerminal("out");
    
            MbMessage inMessage = inAssembly.getMessage();
    
            MbMessage outMessage = new MbMessage(inMessage);
    
            MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
    
            FTPClient ftpClient = new FTPClient();
    
            try {
    
                // Step 1: Get file information from LocalEnvironment
    
                MbElement localEnv = inAssembly.getLocalEnvironment().getRootElement();
    
                String localDirectory = null;
    
                String localFileName = null;
    
                if (localEnv.getFirstElementByPath("$LocalEnvironment/Destination/File/Directory") != null) {
    
                    localDirectory = localEnv.getFirstElementByPath("$LocalEnvironment/Destination/File/Directory").getValueAsString();
    
                }
    
                if (localEnv.getFirstElementByPath("$LocalEnvironment/File/Name") != null) {
    
                    localFileName = localEnv.getFirstElementByPath("$LocalEnvironment/File/Name").getValueAsString();
    
                }
    
                // Log the local directory and file name
    
                System.out.println("Local Directory: " + localDirectory);
    
                System.out.println("Local File Name: " + localFileName);
    
                // Step 2: Connect to the FTP server
    
                String ftpHost = "9.20.192.15"; 
    
                int ftpPort = 21;              
    
                String ftpUser = "builduser";  
    
                String ftpPassword = "builduser"; 
    
                String remoteDirectory = "/MyTest/VendorImport/Dummy/POLLTO"; 
    
                ftpClient.connect(ftpHost, ftpPort);
    
                ftpClient.login(ftpUser, ftpPassword);
    
                // Step 3: List files in the remote FTP directory
    
                String[] ftpFileList = ftpClient.listNames(remoteDirectory);
    
                // Log the list of files retrieved from the FTP server
    
                if (ftpFileList != null) {
    
                    System.out.println("Files in FTP directory:");
    
                    for (String fileName : ftpFileList) {
    
                        System.out.println(fileName);
    
                    }
    
                } else {
    
                    System.out.println("No files found in the FTP directory.");
    
                }
    
                // Step 4: Build output message
    
                MbElement outRoot = outMessage.getRootElement();
    
                MbElement outBody = outRoot.createElementAsLastChild(MbElement.TYPE_NAME, "XMLNSC", null);
    
                MbElement fileListElement = outBody.createElementAsLastChild(MbElement.TYPE_NAME, "FileDetails", null);
    
                // Add local file details from FileOutput Node
    
                if (localDirectory != null) {
    
                    fileListElement.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "LocalDirectory", localDirectory);
    
                }
    
                if (localFileName != null) {
    
                    fileListElement.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "LocalFileName", localFileName);
    
                }
    
                // Add file names from FTP server
    
                if (ftpFileList != null) {
    
                    MbElement ftpFilesElement = fileListElement.createElementAsLastChild(MbElement.TYPE_NAME, "FTPFiles", null);
    
                    for (String fileName : ftpFileList) {
    
                        ftpFilesElement.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "File", fileName);
    
                    }
    
                }
    
                // Step 5: Disconnect from FTP server
    
                ftpClient.logout();
    
                ftpClient.disconnect();
    
            } catch (IOException e) {
    
                throw new MbUserException(this, "evaluate", "", "", e.toString(), null);
    
            }
    
            // Propagate the message to the next node
    
            out.propagate(outAssembly);
    
        }
    
    }
  6. Add Trace Node after Java Compute Node to log the full message tree

FileInput and FileOutput nodes for poll directory activity

About this task

To achieve a Poll Directory functionality in ACE, follow these steps using both the FileInput and FileOutput nodes:

Procedure

  1. Set the Input directory property in the FileInput node to a local directory path, such as C:\Users\Administrator\Desktop\FileInputNodeLocal
  2. Define the file name pattern to identify the files to process (for example, *.txt, *.json,* for multiple files).
    Interface for specifying the input node directory
  3. Set the Polling interval to control how often the node checks the directory for new files
    FTP Remote Transfer is selected, so Polling interval is disabled.Screenshot showing the polling interval selectionInterface showing File Input node propeties specified
  4. Uncheck the FTP Remote Transfer to enable polling, then edit the polling property and save. Select remote transfer to connect FTP endpoint.
    Screenshot showing polling interval, now changed to 10 seconds
  5. In message domain parsing property, select message domain from drop down, for example JSON : for JavaScript Object Notation messages
    Screenshot of drop down listing options for message domain parsing. JSON: For Javascript Object Notation messages is highlighted
  6. Provide the FTP endpoint details under the FTP section in the FileInput node properties.
  7. In the FTP Tab under FileInput node, specify the server directory from which the files will be polled. This should match the location where your files are stored on the FTP server.
  8. Set the directory property in the FileOutput node to a local directory path, such as C:\Users\Administrator\Desktop\FileOutputNodeLocal
    To poll multiple files, use * as a wildcard in the File name or pattern propertyInterface for specifying the directory properties
  9. Provide the FTP endpoint details under the FTP section in the FileOutput node properties.
  10. In the FTP Tab of the FileOutput node, specify the server directory where the files will be written. This is the directory on the FTP server where the processed files will be saved.

Example

Example message flow:

FileInput node > FileOutput node

Configure the File Name or Pattern When Mapped from Other Nodes

About this task

Steps to Pass Filename from FileInput node to FileOutput node with an example

Procedure

  1. Configure FileInput node
    1. Set the input directory to a local directory path such as C:\Users\Administrator\Desktop\FileInputNodeLocal)
    2. Specify the file name or pattern (for example., JSONTEST.json).
    3. Enter FTP connection details in the FTP tab
    4. Set the Message Domain in the (e.g., JSON for JSON files).
  2. Configure FileOutput node
    1. Set to a local directory for example C:\Users\Administrator\Desktop\FileOutputNodeLocal
      Interface for specifying properties for FileOutput node
    2. Enter FTP connection details

Steps to Pass File Name from File Output Node to File Read node example

Procedure

  1. Configure FileOutput node
    1. Set to a local directory for example C:\Users\Administrator\Desktop\FileOutputNodeLocal
    2. Specify the file name or pattern
      Leave it as is because the file will come from FileInput node to FileOutput node
    3. Select "Mode for writing to file" to write directly to the output file
      Append if file exists
    4. In the FTP tab, enter FTP connection details
    5. Set the message domain (for example JSON for JSON files)
  2. Configure FileRead node
    1. Set to a local directory for example C:\Users\Administrator\Desktop\FileReadNode
  3. Give Request file name property location like below
    Interface for specifying FileRead node properties

Configure the Binary Code

About this task

Binary code to handle different encodings such as ISO-8859-1, UTF-8, US-ASCII, Shift-JIS, EBCDIC_XML_US, EUC-JP, and Windows-1252

Coded Character Set Identifier(CCSID) for all different encodings are:Screenshot of different coded character set identifier encodings

Configuring ISO-8859-1 Text Handing in Input Message Parsing

To use text with ISO-8859-1 encoding, follow these steps:

Procedure

  1. Navigate to the Basic Tab:
    1. Open your message flow configuration
    2. Go to the basic tab
  2. Configure Input Message Parsing:
    1. Specify the message coded character set ID (819 (for ISO-8859-1)
    2. Select the message encoding from the list or enter a numeric encoding value
      Message encoding: integration server system determined Interface showing options for message encoding. Integration Server System Determined
      Note: If the incoming message is in ASCII or an ASCII-compatible encoding (for example ISO-8859-1, UTF-8, US-ASCII, Shift-JIS, EBCDIC_XML_US, EUC-JP, and Windows-1252.), the FileOutput node can handle the transfer without requiring a specific CCSID(coded character set ID )

Secure File Transfer Protocol (SFTP)

About this task

Steps to connect to SFTP server:

Procedure

  1. Open your message flow in ACE and drag the appropriate FTP node (for example, FileInput, FileOutput, FileRead or FileExists) to your flow
  2. Configure the SFTP:
    1. In the properties tab, select FTP Tab and select remote transfer checkbox
    2. Select SFTP from drop down in the Transfer protocol property.
    Interface showing options for Transfer protocol. SFTP is highlighted
  3. Set the SFTP Server Connection:
    1. Enter the SFTP server address and the port number for example: 9.30.51.177:22
  4. Security Identity (user name and password authentication):
    Use this command to create securityIdentity for SFTP all Nodes:
    mqsisetdbparms -w workDir -n sftp::myidentity -u <myuserid> -p <mypassword>
    Example:
    mqsisetdbparms -w C:\ACE12NODEWS\TEST_SERVER -n sftp::SFTPSERIDENTITY -u user1 -p Access2sftpuser
    Replace:

    workDir with the working directory of your integration server

    myidentity with a name for the security identity

    userName with the SFTP server username

    password with the SFTP server password

    Screenshot showing example command in App Connect Enterprise console

    Specify the directory on the SFTP server where the files are located (for FileInput node) or the directory where the files should be uploaded (for FileOutput node). For example: /incoming/ for reading files or /outgoing/ for writing files.

    SFTP endpoint details screen:Interface showing SFTP endpoint screen with all properties filled

    Note: After running the command successfully, restart your integration server in IBM App Connect Enterprise (ACE) to apply the changes. Right-click on the integration server (for example TEST_SERVER1) in the IBM App Connect Enterprise Toolkit and select restart.
  5. Use a third-party tool like FileZilla or WinSCP to test the SFTP connection and provide the FTP details (Host, Username, Password, and Port) and connect

File Transfer Protocol Secure

About this task

Steps to connect to the FTPS server

Procedure

  1. Select the FTP node
    Open your message flow in IBM App Connect Enterprise and drag the appropriate FTP node (for, FileInput, FileOutput, File Read or FileExists) to your flow
  2. Configure the FTPS:
    1. In the properties tab, select FTP Tab
    2. Select remote transfer checkbox
    3. Select FTPS from drop down in the transfer protocol property

      In IBM App Connect Professional, when FTPS is selected with explicit TLS, the default port is 21

      Interface showing default port for explicit TLS setting
    4. When FTPS is selected with implicit, the port is 990
      Interface showing default port for implicit TLS setting
    Repeat the same steps from Step 3 to Step 5 as mentioned earlier for FTP. Ensure that these steps are also applicable to FTPS

Certificate Configuration in IBM App Connect Enterprise

About this task

In IBM App Connect Professional, certificates are usually generated from the FTP server and then imported into the Studio using the PGP Utility under the Tools menu.

In IBM App Connect Enterprise, certificate information is configured in the server.conf.yaml file under JVM ResourceManager. You can specify the keystore and truststore details and import the certificate accordingly.

ACE uses a Java KeyStore (JKS) or PKCS12 Truststore to validate SSL/TLS connections.

Steps to configure certificates in IBM App Connect Enterprise

Procedure

  1. Locate the server.conf.yaml file
  2. Create keystore and truest store under JVM ResourceManagers
    For example:

    keystoreType: 'JKS'

    keystoreFile: C:/Users/Administrator/keystore.jks

    keystorePass: <password> (Replace <password> with the actual keystore password)

    truststoreType: 'JKS'

    truststoreFile: C:/Users/Administrator/truststore.jks

    truststorePass: <password> (Replace <password> with the actual truststore password)

  3. After making the changes, restart the IBM App Connect Enterprise integration server for them to take effect