打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Mule3.x中对Ftp协议的支持
1.    前言
一直都听说 Mule 对 Ftp 和 Http 协议的支持很好,于是就关注了一下。
Mule 通过一系列的配置文件的配置就可以完成对 Ftp 服务器的下载和上传 ,这个还是很神奇的。
但是可惜的是, Mule 本身并不支持 FtpS 协议,只支持 SFTP ,这样对于工业级的使用上,未免有点不方便 。
 
2.    Mule 3.x 的基本知识
Mule 是一个开源的 ESB 软件,基本概念如下:
 
Mule 3.X 中对 Ftp 的支持是通过 < ftp:connector> 等标签实现的,具体的官方信息如下:
 
在 Mule 3.x 中,运行 config.xml 的方法如下:
a.       在 app 目录下新建一个目录,比如 test-ftp
b.       将写好的 config.xml 拷贝到 test-ftp 下,并且取名为 mule-config.xml
c.       在 bin 目录下,运行 CMD 如下
Mule –app test-ftp
 
 
3.    Mule 3.x 中 ftp 支持的方法
a.       从 ftp 服务器上下载文件的方法
<? xml version = "1.0" encoding = "UTF-8" ?>
      xmlns:spring = "http://www.springframework.org/schema/beans"
      xmlns:http = "http://www.mulesoft.org/schema/mule/http"
      xmlns:ftp = "http://www.mulesoft.org/schema/mule/ftp"
      xmlns:file = "http://www.mulesoft.org/schema/mule/file"
      xsi:schemaLocation = "
 
<!--
连接 FTP 服务器的连接器
-->
    < ftp:connector name = "ftpConnector" binary = "true"
       validateConnections = "true" />
 
 
    < model name = "ftp-model" >
       < service name = "ftp-reader" >
       <!--
     连接 FTP 服务器的入口节点,在这里配置 ftp 的 ip ,账户和密码
     利用 file:filename-wildcard -filter 确认只下载 xml 文件
     -->
           < inbound >
              < ftp:inbound-endpoint user = "zhany" binary = "true" path = ""
                  password = "zhany" host = "192.168.120.33" port = "21"
                  pollingFrequency = "10000" connector-ref = "ftpConnector"  
                  >
                  < file:filename-wildcard-filter
                     pattern = "*.xml" />
              </ ftp:inbound-endpoint >
           </ inbound >
    <!--
     连接 FTP 服务器的出口节点,在这里配置地址,将文件下载到 e:/out 目录下
     同时利用 outputPattern ,定义下载的文件和源文件同名同类型
     -->
           < outbound >
              < pass-through-router >
                  < file:outbound-endpoint path = "/e:/out" outputPattern = "[header:originalFilename]" />
              </ pass-through-router >
           </ outbound >
 
       </ service >
    </ model >
 
</ mule >
 
 
 
b.       上传文件到 ftp 服务器上的办法
<? xml version = "1.0" encoding = "UTF-8" ?>
      xmlns:spring = "http://www.springframework.org/schema/beans"
      xmlns:http = "http://www.mulesoft.org/schema/mule/http"
      xmlns:ftp = "http://www.mulesoft.org/schema/mule/ftp"
      xmlns:file = "http://www.mulesoft.org/schema/mule/file"
      xsi:schemaLocation = "
<!--
传输文件的连接器
-->
    < file:connector name = "fileConnector" pollingFrequency = "6000" />
<!--
连接 ftp 服务器的连接器
-->
    < ftp:connector name = "ftpConnector" />
   
    < model name = "model" >
       < service name = "service" >
           < inbound >
           <!--
        利用 fileConnector 读取 e:/tmp 下的文件
       -->
              < file:inbound-endpoint path = "/e:/tmp"
                  connector-ref = "fileConnector" >
              </ file:inbound-endpoint >
           </ inbound >
           < outbound >
              <!--
        利用 ftpConnector 将文件传输到 ftp 服务器上,这里配置了服务器的 ip 和账户密码
       -->
              < pass-through-router >
                  < ftp:outbound-endpoint host = "192.168.120.33"
                     port = "21" user = "zhany" password = "zhany" path = "" connector-ref = "ftpConnector" />
              </ pass-through-router >
           </ outbound >
       </ service >
    </ model >
</ mule >
 
 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/nanjingjiangbiao/archive/2010/10/11/5933923.aspx
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
将博客搬至CSDN
CAN收发器TJA1040简介-CSDN博客
调试信息的输出
写CSDN博客时表格内如何换行
LoadRunner中的多进程和多线程
SqlServer删除主键和重建主键
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服