Mule通过HTTP发布XML文件

时间:2015-06-11 15:34:53

标签: xml http mule

我正在尝试使用MULE通过HTTP将XML文件发布到Web服务,但无论我尝试它,都会抱怨有效负载类型。我目前的Mule配置是:

<file:connector name="File" writeToDirectory="C:\Users\mark.gordon\Documents\Timesheets" readFromDirectory="C:\Users\mark.gordon\Documents\Timesheets" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="cpa-test.mcnicholas.co.uk" port="443" basePath="/cgi-bin/portal" doc:name="HTTP Request Configuration" tlsContext-ref="TLS_Context">
</http:request-config>
<tls:context name="TLS_Context" doc:name="TLS Context">
    <tls:trust-store path="C:\Program Files\Java\jre7\lib\security\cacert" password="changeit"/>
</tls:context>
<http:request-config name="HTTP_Request_Configuration1" protocol="HTTPS" host="cpa-live.mcnicholas.co.uk" port="443" basePath="/cgi-bin/portal" doc:name="HTTP Request Configuration"/>
<flow name="timesheetsFlow">
    <file:inbound-endpoint path="C:\Users\mark.gordon\Documents\Timesheets" moveToDirectory="C:\Users\mark.gordon\Documents\Timesheets\Processed" connector-ref="File" responseTimeout="10000" doc:name="File">
        <file:filename-regex-filter pattern="A.*\.xml" caseSensitive="false"/>
    </file:inbound-endpoint>
    <mulexml:xslt-transformer xsl-file="C:\Users\mark.gordon\AnypointStudio\workspace\timesheets\Stylesheets\ts-sp-to-cpa.xsl" maxIdleTransformers="2" maxActiveTransformers="5" doc:name="XSLT"/>
    <set-attachment attachmentName="timesheet" value="#[payload]" contentType="text/xml" doc:name="Attachment"/>
    <http:request config-ref="HTTP_Request_Configuration1" path="main" method="POST" doc:name="HTTP" followRedirects="true" responseTimeout="300">
        <http:request-builder>
        </http:request-builder>
    </http:request>
</flow>

稍后我会在发布之前使用XSLT对XML进行转换,但我已经将其删除了,因为如果没有它我甚至无法发布它!

将代码发布后,我得到以下异常:

Message               : Error sending HTTP request. Message payload is of type: byte[]
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.util.concurrent.TimeoutException)
  org.glassfish.grizzly.impl.SafeFutureImpl$Sync:357 (null)
2. Error sending HTTP request. Message payload is of type: byte[] (org.mule.api.MessagingException)
  org.mule.module.http.internal.request.DefaultHttpRequester:190 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.util.concurrent.TimeoutException
    at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerGet(SafeFutureImpl.java:357)
    at org.glassfish.grizzly.impl.SafeFutureImpl.get(SafeFutureImpl.java:264)
    at com.ning.http.client.providers.grizzly.GrizzlyResponseFuture.get(GrizzlyResponseFuture.java:173)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

1 个答案:

答案 0 :(得分:0)

你得到一个var auth = string.Format("auth {0}\n", hash); byte[] outStream = System.Text.Encoding.ASCII.GetBytes(auth); serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush(); serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize); // Don't forget to read the response!! returndata = System.Text.Encoding.ASCII.GetString(inStream); :我怀疑防火墙阻止你POST到这个特定的端点。