How to use SFTP
23-02-2017
Abstract
• The main motto of this PPT is how to use SFTP
in our applications.
Introduction:
The SFTP Connector implements a secure file
transport channel so that your Mule application can
exchange files with external resources. SFTP uses
the SSH security protocol to transfer messages. You
can implement the SFTP endpoint as an inbound
endpoint with a one-way exchange pattern, or as an
outbound endpoint configured for either a one-way
or request-response exchange pattern.
Example
• .mflow
• <?xml version="1.0" encoding="UTF-8"?>
• <mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
• xmlns:spring="http://www.springframework.org/schema/beans"
• xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
• xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-current.xsd
• http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
• http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
• http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
• <sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP"/>
• <flow name="SFTPFlow">
• <sftp:inbound-endpoint connector-ref="SFTP" host=“***************" port=“*******"
path="/incoming/input" user=“*******" password=“**********" responseTimeout="10000" doc:name="SFTP"/>
• <logger message="---After SFTP-----" level="INFO" doc:name="Logger"/>
• <file:outbound-endpoint path="C:SFTP POCOutput" responseTimeout="10000" doc:name="File"
outputPattern="myfile.txt"/>
• </flow>
• </mule>
• Output:
• **********************************************************************
• * default * DEPLOYED *
• **********************************************************************
• ********************************************************************************
***********************
• * - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - *
• ********************************************************************************
***********************
• * SFTP * default * DEPLOYED *
• ********************************************************************************
***********************
• INFO 2017-02-23 11:35:01,508 [[SFTP].SFTPFlow.stage1.02]
org.mule.api.processor.LoggerMessageProcessor: ---After SFTP-----
• INFO 2017-02-23 11:35:01,567 [[SFTP].connector.file.mule.default.dispatcher.01]
org.mule.lifecycle.AbstractLifecycleManager: Initialising:
'connector.file.mule.default.dispatcher.1217240011'. Object is: FileMessageDispatcher
• INFO 2017-02-23 11:35:01,588 [[SFTP].connector.file.mule.default.dispatcher.01]
org.mule.lifecycle.AbstractLifecycleManager: Starting:
'connector.file.mule.default.dispatcher.1217240011'. Object is: FileMessageDispatcher
• INFO 2017-02-23 11:35:01,629 [[SFTP].connector.file.mule.default.dispatcher.01]
org.mule.transport.file.FileConnector: Writing file to: C:SFTP POCOutputmyfile.txt
References
• https://docs.mulesoft.com/mule-user-
guide/v/3.6/sftp-connector

How to use SFTP

  • 1.
    How to useSFTP 23-02-2017
  • 2.
    Abstract • The mainmotto of this PPT is how to use SFTP in our applications.
  • 3.
    Introduction: The SFTP Connectorimplements a secure file transport channel so that your Mule application can exchange files with external resources. SFTP uses the SSH security protocol to transfer messages. You can implement the SFTP endpoint as an inbound endpoint with a one-way exchange pattern, or as an outbound endpoint configured for either a one-way or request-response exchange pattern.
  • 4.
  • 5.
    • .mflow • <?xmlversion="1.0" encoding="UTF-8"?> • <mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" • xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" • xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd • http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd • http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd • http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd"> • <sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP"/> • <flow name="SFTPFlow"> • <sftp:inbound-endpoint connector-ref="SFTP" host=“***************" port=“*******" path="/incoming/input" user=“*******" password=“**********" responseTimeout="10000" doc:name="SFTP"/> • <logger message="---After SFTP-----" level="INFO" doc:name="Logger"/> • <file:outbound-endpoint path="C:SFTP POCOutput" responseTimeout="10000" doc:name="File" outputPattern="myfile.txt"/> • </flow> • </mule>
  • 6.
    • Output: • ********************************************************************** •* default * DEPLOYED * • ********************************************************************** • ******************************************************************************** *********************** • * - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - * • ******************************************************************************** *********************** • * SFTP * default * DEPLOYED * • ******************************************************************************** *********************** • INFO 2017-02-23 11:35:01,508 [[SFTP].SFTPFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: ---After SFTP----- • INFO 2017-02-23 11:35:01,567 [[SFTP].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.dispatcher.1217240011'. Object is: FileMessageDispatcher • INFO 2017-02-23 11:35:01,588 [[SFTP].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.dispatcher.1217240011'. Object is: FileMessageDispatcher • INFO 2017-02-23 11:35:01,629 [[SFTP].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:SFTP POCOutputmyfile.txt
  • 7.