MULE可以通过HTTP从本地目录发布XML文件吗?

时间:2013-05-17 14:10:51

标签: http post mule

我需要通过HTTP POST传输XML文件。可以配置Mule来执行此操作。我一直在尝试一个简单的流量,入站文件 - >超出HTTP,但它不起作用。有没有人有这方面的经验?

    <flow name="rpg_uploadFlow1" doc:name="rpg_uploadFlow1">
    <file:inbound-endpoint path="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\OUT" moveToDirectory="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\sent" responseTimeout="10000" mimeType="text/xml" doc:name="File"/>
    <http:outbound-endpoint exchange-pattern="one-way" host="http://XXXXXXXXXXX.ashx?SystemName=XXXX&amp;UserName=XXXX&amp;PassWord=XXXXX" port="80" disableTransportTransformer="true" doc:name="HTTP"/>

</flow>

错误;

ERROR 2013-05-17 17:24:49,208 [[rpg_upload].connector.http.mule.default.dispatcher.07]    org.mule.exception.DefaultMessagingExceptionStrategy: 

Message               : Failed to route event via endpoint:   DefaultOutboundEndpoint{endpointUri=http://http://xxxxxxxxxxxxxxxx/rpgtest/service.ashx?  SystemName=xxxxxxxxxxxxxxxxx&UserName=xxxxxxxxxxxxxxx&PassWord=xxxxxxx,  connector=HttpConnector
{
   name=connector.http.mule.default
  lifecycle=start
  this=18b44ce0
   numberOfConcurrentTransactedReceivers=4
   createMultipleTransactedReceivers=true
   connected=true
   supportedProtocols=[http]
   serviceOverrides=<none>
 }
 ,       name='endpoint.http.http.xxxxxxxxxxxxxxxx.service.ashx.SystemName.xxxxx.UserName.xxxxx.Pass       Word.836749.80', mep=ONE_WAY, properties={PassWord=836749:80, SystemName=xxxxxx,      UserName=xxxxxxxxx}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=true}. Message payload is of type: ReceiverFileInputStream
    Code                  : MULE_ERROR-42999
 --------------------------------------------------------------------------------
 Exception stack is:
 1. http (java.net.UnknownHostException)
  java.net.AbstractPlainSocketImpl:-1 (null)
 2. Failed to route event via endpoint:   DefaultOutboundEndpoint{endpointUri=http://http://xxxxxxxxxx.ashx?   SystemName=xxxxxxxxxxxx&UserName=xxxxxx&PassWord=836749:80, connector=HttpConnector
 {
   name=connector.http.mule.default
   lifecycle=start
   this=18b44ce0       
   numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
   connected=true
  supportedProtocols=[http]
  serviceOverrides=<none>
      }
    ,        name='endpoint.http.http.xxxx.ashx.SystemName.xxxxxxxx.UserName.xxxxx.PassWord.836749.80',     mep=ONE_WAY, properties={PassWord=836749:80, SystemName=xxxxxxxxxx, UserName=xxxx},    transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0},    deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000,    endpointEncoding=UTF-8, disableTransportTransformer=true}. Message payload is of type:    ReceiverFileInputStream (org.mule.api.transport.DispatchException)
       org.mule.transport.http.HttpClientMessageDispatcher:155    (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchExceptio n.html)
      --------------------------------------------------------------------------------
      Root Exception stack trace:
      java.net.UnknownHostException: http
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
at   java.net.SocksSocketImpl.connect(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

3 个答案:

答案 0 :(得分:1)

我在文件端点的某些位置遇到了麻烦,因为它传递了文件读取器作为有效负载而不是实际文本。尝试添加文件到字符串转换器:

<flow name="rpg_uploadFlow1" doc:name="rpg_uploadFlow1">
    <file:inbound-endpoint path="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\OUT" moveToDirectory="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\sent" responseTimeout="10000" mimeType="text/xml" doc:name="File"/>
    <file:file-to-string-transformer doc:name="File to String"/>
    <http:outbound-endpoint exchange-pattern="one-way" host="http://XXXXXXXXXXX.ashx?SystemName=XXXX&amp;UserName=XXXX&amp;PassWord=XXXXX" port="80" disableTransportTransformer="true" doc:name="HTTP"/>
</flow>

答案 1 :(得分:1)

你可以使用一个mule字节数组来串起变换器,使你的请求成为字符串,然后将其发布到你的http出站。

<flow name="rpg_uploadFlow1" doc:name="rpg_uploadFlow1">
    <file:inbound-endpoint path="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\OUT" moveToDirectory="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\sent" responseTimeout="10000" mimeType="text/xml" doc:name="File"/>

    <byte-array-to-string-transformer></byte-array-to-string-transformer>
  .....

出现错误。我猜它与骡子标签和端点无关。这是访问您正在尝试的网址的东西。

请参阅以下帖子,了解与UnknownHostException相关的问题。

java.net.UnknownHostException when accessing a URL

答案 2 :(得分:0)

试试这个: 您可以使用一个mule字节数组来串起变换器,将您请求的File作为字符串,然后使用SetPayload或Attachment Connector并将其发布到您的http出站。