Mule HTTP入站端点从HTTP出站端点转发HTTP头

Mule HTTP入站端点从HTTP出站端点转发HTTP头,mule,Mule,早上好 我正在使用Mule将输入转换为Web API并从中输出。我有以下流程: <http:inbound-endpoint exchange-pattern="request-response" host="${webapi.host.server}" port="${webapi.host.port}" path="${webapi.getData.host.data.path}" doc:name="Incoming Requet" contentType="text/xml" mi

早上好

我正在使用Mule将输入转换为Web API并从中输出。我有以下流程:

<http:inbound-endpoint exchange-pattern="request-response" host="${webapi.host.server}" port="${webapi.host.port}" path="${webapi.getData.host.data.path}" doc:name="Incoming Requet" contentType="text/xml" mimeType="text/xml"/>
<message-properties-transformer doc:name="Message Properties">
    <add-message-property key="Accept" value="application/json"/>
</message-properties-transformer>
<set-payload value="{ SortBy: &quot;LastModificationTimestamp&quot;, FirstResult: 1, ResultsToRetrieve: #[message.inboundProperties[&quot;count&quot;] ==null ? &quot;10&quot; : message.inboundProperties[&quot;count&quot;]] }" doc:name="Set FO Input (JSON)"/>
<http:outbound-endpoint exchange-pattern="request-response" host="${dataSource.host.server}" port="${dataSource.host.port}" method="POST" doc:name="HTTP" contentType="application/json" password="${dataSource.host.password}" path="${dataSource.host.dataSource.path}" user="${dataSourceities.host.user}" responseTimeout="${dataSourceities.host.responseTimeout}"/>
<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
<expression-component  doc:name="Expression">message.payload = message.payload.Results</expression-component>
<jdbc-ee:maps-to-xml-transformer doc:name="Maps to XML" mimeType="text/xml"/>
<message-properties-transformer doc:name="Message Properties" scope="outbound">
    <delete-message-property key="Content-Type"/>
    <delete-message-property key="Set-Cookie"/>
</message-properties-transformer>
<message-properties-transformer doc:name="Message Properties" scope="outbound">
    <add-message-property key="Content-Type" value="application/xml"/>
</message-properties-transformer>
但是!当我使用Fiddler调用Mule时,Mule返回的头包括出站调用返回的所有头。具体地说,这两个参数设置Cookie和内容类型。显然,我希望结果是
application/xml

HTTP/1.1 200 OK
Date: Wed, 05 Feb 2014 11:54:13 -0500
Server: Mule EE Core Extensions/3.4.0
Set-Cookie: Some-Cookie-From-the-Original-Web-API=chocolate-chip; Domain=localhost; Path=/
Set-Cookie: Other-Cookie-From-the-Original-Web-API=oatmeal-raisin; Domain=localhost; Path=/; Expires=Fri, 7-Feb-2014 16:54:08 GMT
Content-Type: application/json
X-MULE_SESSION: big-long-string
X-MULE_ENCODING: utf-8
Content-Length: 86952
Connection: close

问题:在这种情况下,如何将内容类型设置为application/xml?为了获得额外的积分,我该如何将这些其他标题导出?

我无法重现此问题,您不需要使用属性转换器。我正在使用Mule Studio 3.5.0并与Postman一起测试。如果您使用的是较旧的Mule版本,请尝试对其进行更新,并将内容类型头/消息记录在Mule中。我使用以下配置进行了测试:

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="test" doc:name="HTTP"/>
<message-properties-transformer doc:name="Message Properties">
   <add-message-property key="Accept" value="application/json"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" host="echo.jsontest.com" port="80" contentType="application/json" path="key/value/one/two" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
<jdbc-ee:maps-to-xml-transformer doc:name="Maps to XML" mimeType="text/xml"/>
<logger message="#[header:OUTBOUND:Content-Type]" level="INFO" doc:name="Logger"/>

最后记录器打印出
text/xml;charset=ISO-8859-1
,这也是返回给邮递员的内容

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="test" doc:name="HTTP"/>
<message-properties-transformer doc:name="Message Properties">
   <add-message-property key="Accept" value="application/json"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" host="echo.jsontest.com" port="80" contentType="application/json" path="key/value/one/two" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
<jdbc-ee:maps-to-xml-transformer doc:name="Maps to XML" mimeType="text/xml"/>
<logger message="#[header:OUTBOUND:Content-Type]" level="INFO" doc:name="Logger"/>