【问题标题】:Mule outbound http end point Content-Length mismatchMule 出站 http 端点 Content-Length 不匹配
【发布时间】:2013-04-18 17:25:47
【问题描述】:

我正在尝试从一个 REST 客户端到另一个客户端执行基本的 GET/POST。我很好地获取和映射数据,但在 POST http 出站端点期间超时。在使用 Fiddler Web Debugger 时,我发现问题出在 Content-Length 上。我收到错误“内容长度不匹配:RequestHeader 指示 403 个字节,但客户端发送了 61 个字节。”

如果使用以下语法手动设置 Content-Length,则可以正常工作:

<message-properties-transformer scope="outbound>
    <add-message-property key="Content-Type" value="application/json"/>
    <add-message-property key="Content-Length" value="61"/>
</message-properties-transformer>

我不明白为什么 Content-Length 不正确。我无法将其硬编码为 61,因为我要传输的记录总是会有不同的长度。

任何想法将不胜感激。

布雷特

注意:这是完整的流程:

<http:endpoint exchange-pattern="request-response" host="slcomax.ameipro.com" port="80" path="maxrest/rest/mbo/worktype/115?_lid=mxintadm&amp;_lpwd=mxintadm" method="GET" name="HTTP" doc:name="HTTP"/>
<data-mapper:config name="maxtondtypes" transformationGraphPath="maxtondtypes.grf" doc:name="maxtondtypes"/>
<flow name="ruby_rest_testerFlow1" doc:name="ruby_rest_testerFlow1">
    <quartz:inbound-endpoint jobName="getTypes" repeatInterval="600000" responseTimeout="10000" doc:name="Quartz">
        <quartz:endpoint-polling-job>
            <quartz:job-endpoint ref="HTTP"/>
        </quartz:endpoint-polling-job>
    </quartz:inbound-endpoint>
    <echo-component doc:name="Echo"/>
    <data-mapper:transform config-ref="maxtondtypes" doc:name="DataMapper"/>
    <echo-component doc:name="Echo"/>
    <http:outbound-endpoint exchange-pattern="request-response" host="ndeavor.ameipro.com" port="80" path="types" doc:name="HTTP" contentType="application/json">
        <message-properties-transformer scope="outbound"> 
            <add-message-property key="Content-Type" value="application/json"/>
            <!-- <add-message-property key="Content-Length" value="61"/> -->
        </message-properties-transformer> 
    </http:outbound-endpoint>
    <echo-component doc:name="Echo"/>
</flow>

【问题讨论】:

  • 你能展示更多的流程吗?似乎在 HTTP 出站端点引起麻烦之前发生了一些事情。还有:骡版?
  • 大卫,我刚刚将它添加到原始帖子中。
  • 谢谢。只是为了记录echo-component 是支持旧的,不应该再使用了。更喜欢使用logger
  • 好的,我相信的版本也是3.3.2

标签: mule endpoint


【解决方案1】:

问题是由于 Quartz 入站端点处理端点轮询的方式:它获取从端点交互接收到的所有属性并将它们放在 outbound 范围内,这完全弄乱了下游的内容。这是一个错误 IMO:属性应该放在入站范围内。

作为记录,这是 Quartz 轮询器放入出站范围的内容:

Cache-Control=no-cache
Content-Language=en-US
Content-Length=360
Content-Type=application/json
Date=Thu, 18 Apr 2013 18:00:12 GMT
Expires=Thu, 01 Dec 1994 16:00:00 GMT
MULE_ENCODING=UTF-8
Server=IBM_HTTP_Server
Set-Cookie=JSESSIONID=0000TRNJZ71m3RLX-NDBwfC-quo:-1; Path=/

因为所有这些属性都在出站范围内,http:outbound-endpoint 将它们拾取并使用它们...因此内容长度错误(更不用说它也无缘无故发送的所有其他疯狂标头)。

解决方法是使用HTTP轮询连接器代替Quartz,如下图:

<http:connector name="httpConnector" />
<http:polling-connector name="httpPollingConnector"
    pollingFrequency="600000" />

<http:endpoint name="worktypePoller" exchange-pattern="request-response"
    host="slcomax.ameipro.com" port="80"
    path="maxrest/rest/mbo/worktype/115?_lid=mxintadm&amp;_lpwd=mxintadm"
    method="GET" connector-ref="httpPollingConnector" />

<flow name="ruby_rest_testerFlow1">
    <http:inbound-endpoint ref="worktypePoller" />
    <data-mapper:transform config-ref="maxtondtypes" />
    <http:outbound-endpoint exchange-pattern="request-response"
        host="ndeavor.ameipro.com" port="80" path="types" connector-ref="httpConnector">
        <set-property propertyName="Content-Type" value="application/json" />
    </http:outbound-endpoint>
</flow>

【讨论】:

  • 大卫,我非常感谢你......我相信你已经知道了,但它就像一个魅力。
猜你喜欢
  • 2013-02-22
  • 1970-01-01
  • 2012-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-17
  • 1970-01-01
相关资源
最近更新 更多