SFTP Client Adapter

The SFTP Client adapter sends SFTP requests to trading partners through perimeter services.

The SFTP Client adapter has the following major features:
  • Uses perimeter services
  • Commands are scriptable through BPML
  • Works easily with most SFTP servers
  • Accessible through the following services in a business process:
    • SFTP Client Begin Session service
    • SFTP Client CD service
    • SFTP Client DELETE service
    • SFTP Client End Session service
    • SFTP Client GET service
    • SFTP Client LIST service
    • SFTP Client MKDIR service
    • SFTP Client MOVE service
    • SFTP Client PUT service
    • SFTP Client PWD service
    • SFTP Client RMDIR service

The following table provides an overview of the SFTP Client adapter:

Category Description
System name SFTP Client Adapter
Graphical Process Modeler (GPM) category None
Description Sends SFTP requests to trading partners through perimeter services.
Business usage Use this adapter to send SFTP requests to perform activities such as to get or put files into a directory on the trading partner's SFTP server.
Usage example A business process is executed that translates a document to send to a trading partner. After the translation, the SFTP Client adapter sends the document to the trading partner.
Preconfigured? Yes
Requires third-party files? No
Platform availability All Sterling B2B Integrator supported platforms
Related services The following services are related. Configured in a business process, they initiate the SFTP Client adapter to perform their operations:
  • SFTP Client Begin Session service
  • SFTP Client CD service
  • SFTP Client DELETE service
  • SFTP Client End Session service
  • SFTP Client GET service
  • SFTP Client LIST service
  • SFTP Client MOVE service
  • SFTP Client PUT service
  • SFTP Client PWD service
Application requirements An SFTP Server at the external trading partner location. When this adapter is configured with a 'non-local-mode' perimeter server, the perimeter server must be installed and running. The perimeter server is typically installed in a DMZ environment, separated from Sterling B2B Integrator by a firewall. Refer to the perimeter services documentation for details on installing and running that component.
Initiates business processes? No
Invocation This adapter is not invoked from a business process.
Business process context considerations Business processes using SFTP client services should not be marked as Auto Resume. These services require an established session which will no longer exist after a restart.
Returned status values None
Restrictions None
Persistence level N/A
Testing considerations To test this adapter, run the SFTPClientDemoAllServices business process and verify that it completes successfully. For more information about the SFTPClientDemoAllServices business process, see the Business Process Example of All SFTP Client Services. Debug information for this adapter is located at:Operations > System > Logs > SFTP Client Adapter and Services.

Implementing the SFTP Client Adapter

To implement the SFTP Client adapter, complete the following tasks:
  1. Create an SFTP Client adapter configuration. See Managing Services and Adapters.
  2. Configure the SFTP Client adapter. See Configuring the SFTP Client Adapter.

Configuring the SFTP Client Adapter

To configure the SFTP Client adapter:
  1. Select Deployment > Services > Configuration.
  2. Search for SFTP Client adapter or select it from the list.
  3. Click Edit.
  4. Specify field settings:
    Note: (Sterling B2B Integrator 5.2.4.0 and higher) If you do not want to use CBC ciphers, set the supportCBCCiphers property in security.properties to false. The default value is true.
    Field Description
    Name Name this adapter will have in Sterling B2B Integrator
    Description Description of adapter
    Select a Group Select one of the options:
    • None – You do not want to include this configuration in a group at this time.
    • Create New Group – You can enter a name for a new group in this field, which will then be created along with this configuration.
    • Select Group – If you have already created one or more groups for this adapter type, they are displayed in the list. Select a group from the list.
    Note: For more information about groups, see Managing Services and Adapters.
    Perimeter Server List of perimeter servers, including local-mode perimeter servers. Required.
    Minimum Number of Threads A tuning parameter that indicates the range of threads available for handling events to improve performance. See Performance and Tuning for more information. Must be less than or equal to Maximum Number of Threads values. Required.
    Maximum Number of Threads A tuning parameter that indicates the range of threads available for handling events to improve performance. See Performance and Tuning for more information. Must be greater than or equal to Minimum Number of Threads value. Required.
    Local Port Range Any valid port numbers not being used by another application running on the system. A port in the specified range will be used to establish an SSH channel to the remote SFTP server. Optional. Valid values are:(empty) - system selects an available port0 - system selects an available portnnnn - use specified port nnnn, for example 9012nn-yy - use a port in the range of nn to yy, for example 462-863 would use a port in the range of 462 to 863, inclusiveMultiples of the above values can be specified, separated by commas, for example 9012, 462-863, 4925.
    Use SOCKS5 Proxy Server Whether to use a SOCKS5 proxy server. Required. Valid values are:
    • Yes – A SOCKS5 proxy server will be used
    • No – No proxy server will be used
    Proxy hostname A valid proxy server hostname or IP address to use as a gateway. Required if Use SOCKS5 proxy server is set to Yes.
    Proxy port Listen port number of the proxy server. Required if Use SOCKS5 proxy server is set to Yes.
    Proxy retries The number of attempts to connect to the proxy server if the connection is unsuccessful. Valid values can be any integer between 0 and 50. Default is 3.
    Use proxy basic authentication Whether the proxy server requires basic authentication. Valid values are:
    • Yes – Proxy basic authentication will be used
    • No – Proxy basic authentication will not be used
    Proxy username Username to connect to the proxy server.
    Proxy password Password to connect to the proxy server.
    Transfer Mode File transfer mode. Valid values are ASCII or BINARY. The default mode is BINARY.

    You can switch the mode to BINARY or ASCII using the UI or the SFTPClientBeginSession BP. The key is TransferMode and value is MODE_TEXT or MODE_BINARY.

    To override the transfer mode in a BP, add as shown below:

    <assign to="TransferMode">MODE_TEXT</assign>

    Or

    <assign to="TransferMode">MODE_BINARY</assign>
    Note: You cannot switch the transfer mode within a single session. You can transfer n number of files in one session all using one transfer mode either ASCII or BINARY mode.

Business Process Example of All SFTP Client Services

To help you get started using the SFTP Client adapter and SFTP Server adapter, Sterling B2B Integrator includes a demo that provides an example of all the services. The demo transfers a file from the SFTP Client adapter to the SFTP Server adapter. The following graphic is the business process model of SFTPClientDemoAllServices:

SFTPClientDemoAllServices: graphical model

The BPML code associated with SFTPClientDemoAllServices is shown below:

<!-- Import service initializes mailboxes. Creating mailboxes, 
      permissions and Virtual Root if they do not exist.-->
   <operation name="Import Service">
      <participant name="ImportService"/>
     <output message="ImportTypeInputMessage">
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="ImportServiceResults" from="*"></assign>
     </input>
    </operation>
<!--  Mailbox Delete Service deletes messages in all mailboxes below virtual
      root mailbox. MailboxPath is commented out but could be used to
      delete messages in a specific mailbox. -->
<operation name="Mailbox Delete Service">
      <participant name="MailboxDelete"/>
      <output message="MailboxDeleteServiceTypeInputMessage">
       <assign to="MessageNamePattern">message*</assign>
       <assign to="UserId">admin</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="MailboxDeleteServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- Mailbox Add Service adds Primary Document as message1 in mailbox sub1 -->
    <operation name="Mailbox Add Service">
      <participant name="MailboxAdd"/>
     <output message="MailboxAddServiceTypeInputMessage">
       <assign to="MailboxPath">/sub1</assign>
       <assign to="MessageName">message1</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="MailboxAddServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- Mailbox Add Service adds Primary Document as message2 in mailbox sub1 -->
    <operation name="Mailbox Add Service">
      <participant name="MailboxAdd"/>
     <output message="MailboxAddServiceTypeInputMessage">
       <assign to="MailboxPath">/sub1</assign>
       <assign to="MessageName">message2</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="MailboxAddServiceResults" from="*"></assign>
     </input>
    </operation>
   <!-- Get obscured password -->
    <operation name="Obscure Password">
      <participant name="FTPClientObscureParameter"/>
      <output message="outmsg">
        <assign to="." from="*"></assign>
      </output>
     <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
   </operation>
   <!-- Begin Session -->
    <operation name="SFTP Client Begin Session Service">
     <participant name="SFTPClientBeginSession"/>
     <output message="SFTPClientBeginSessionServiceTypeInputMessage">
       <assign to="SFTPClientAdapter">SFTPClientAdapter</assign>
       <assign to="RemoteHost">carvey</assign>
       <assign to="RemotePasswd" from="admin/text()"></assign>
       <assign to="RemotePort">60849</assign>
       <assign to="RemoteUserId">ftpdemo</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientBeginSessionServiceResults" from="*"></assign>
     </input>
    </operation>
   <!-- SFTP Client PWD Service returns current directory -->
   <operation name="SFTP Client PWD Service">
     <participant name="SFTPClientPwd"/>
     <output message="SFTPClientPwdServiceTypeInputMessage">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientPwdServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client LIST Service returns directories and files under tag 
     ListNames -->
   <operation name="SFTP Client LIST Service">
      <participant name="SFTPClientList"/>
      <output message="SFTPClientListServiceTypeInputMessage">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientListServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client SFTP CD SERVICE changes to directory assigned to tag 
     Directory -->
    <operation name="SFTP Client SFTP CD SERVICE">
      <participant name="SFTPClientCd"/>
      <output message="CdRequest1">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <!--<assign to="Directory" 
                 from="SFTPClientListServiceResults/ListNames/Name[1]/text()">
           </assign>-->
     <assign to="Directory" 
           from="SFTPClientListServiceResults/Files/File[1]/Name/text()">
     </assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientCdServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client LIST Service returns directories and files under tag
     ListNames -->
    <operation name="SFTP Client LIST Service">
      <participant name="SFTPClientList"/>
      <output message="SFTPClientListServiceTypeInputMessage">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientListServiceResults2" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client GET Service retrieves files specified by RemoteFilePattern or 
     RemoteFileName from current directory or from value identified by tag 
     RemoteDirectory if specified. -->
   <operation name="SFTP Client GET Service">
     <participant name="SFTPClientGet"/>
     <output message="SFTPClientGetServiceTypeInputMessage">
      	<assign to="RemoteFileName" 
             from="SFTPClientListServiceResults2/Files/File[Name/text()=
                  'message2']/Name/text()">
       </assign>
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientGetServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client SFTP CD SERVICE changes to directory assigned to tag
     Directory -->
    <operation name="SFTP Client SFTP CD SERVICE">
      <participant name="SFTPClientCd"/>
      <output message="CdRequest1">
	<assign to="Directory">../sub2</assign>
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientCdServiceResults2" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client PUT Service performs the ftp command put. The Primary
     Document contains the files to be put. RemoteFileDirectory is 
    omitted. The files are placed in the current remote directory. -->
   <operation name="SFTP Client PUT Service">
     <participant name="SFTPClientPut"/>
     <output message="SFTPClientPutServiceTypeInputMessage">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." from="SFTPClientGetServiceResults/DocumentId" append=
         "true"/>
      </output>
     <input message="inmsg">
        <assign to="SFTPClientPutServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client Move Service performs the ftp move command renaming
     message1 to message1_renamed in the same directory. -->
   <operation name="SFTP Client MOVE Service">
     <participant name="SFTPClientMove"/>
     <output message="SFTPClientMoveServiceTypeInputMessage">
       <assign to="RemoteFromFileName">message2</assign>
       <assign to="RemoteToFileName">message2_renamed</assign>
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." 
             from="SFTPClientGetServiceResults/DocumentList" append="true"/>
      </output>
     <input message="inmsg">
        <assign to="SFTPClientMoveServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client SFTP CD SERVICE changes to directory assigned to tag
     Directory -->
    <operation name="SFTP Client SFTP CD SERVICE">
      <participant name="SFTPClientCd"/>
      <output message="CdRequest1">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="Directory">..</assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientCdServiceResults3" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client Move Service performs the ftp move command moving message
     from mailbox sub1 to mailbox sub2. -->
   <operation name="SFTP Client MOVE Service">
     <participant name="SFTPClientMove"/>
     <output message="SFTPClientMoveServiceTypeInputMessage">
       <assign to="RemoteFromFileName">sub2/message2_renamed</assign>
       <assign to="RemoteToFileName">sub3/message2</assign>
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientMoveServiceResults2" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client Delete Service removes files from directories. In this
     case removes message1 from sub1 -->
    <operation name="SFTP Client DELETE Service">
    <participant name="SFTPClientDelete"/>
      <output message="DeleteRequest">
        <assign to="SessionToken" 
              from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
        </assign>
       <assign to="RemoteFileName">sub3/message2</assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientDeleteServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client LIST Service returns directories and files under tag
     ListNames -->
    <operation name="SFTP Client LIST Service">
      <participant name="SFTPClientList"/>
      <output message="SFTPClientListServiceTypeInputMessage">
	      <assign to="RemoteFileName">sub2/*</assign>
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientListServiceResults3" from="*"></assign>
     </input>
    </operation>
<!-- SFTP Client End Session Service, ends session specified by SessionToken.-->
   <operation name="SFTP Client End Session Service">
     <participant name="SFTPClientEndSession"/>
     <output message="SFTPClientEndSessionServiceTypeInputMessage">
       <assign to="SessionToken" 
             from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
       </assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="inmsg">
       <assign to="SFTPClientEndSessionServiceResults" from="*"></assign>
     </input>
    </operation>
<!-- To catch all onFault handling to log an error to PsSftpClient -->
     <onFault>
        <sequence name="End Session">
          <operation name="SFTP Client End Session Service">
            <participant name="SFTPClientEndSession"/>
           <output message="SFTPClientEndSessionServiceTypeInputMessage">
             <assign to="SessionToken" 
                from="SFTPClientBeginSessionServiceResults/SessionToken/text()">
             </assign>
             <assign to="." from="*"></assign>
           </output>
            <input message="inmsg">
              <assign to="SFTPClientEndSessionServiceOnFaultResults" from="*">
              </assign>
           </input>
          </operation>
       </sequence>
       </onFault>

Activity Monitoring for the SFTP Client Adapter

The SFTP Client adapter creates activity monitoring records for the following activities:
  • Active sessions
  • In progress PUTs display the data transferred in kbps with a progress indicator
  • In progress GETs display the data transferred in kbps

Select Business Processes > Current Activities > SFTP Client Adapter.