从request-config中删除标头,而不是从MULE 4中删除流

时间:2019-06-13 13:15:01

标签: mule mule-component mule-esb mule4

我正在尝试找到一种解决方案,该解决方案通过比实际更有效的方式删除MULE 4中的请求标头。 在请求配置中可能有<http:default-headers />,但我找不到从此处删除标头的方法。所以我在流中删除标题-> 像这样:

    <http:headers>#[attributes.headers -- ["host", "http.headers"]]</http:headers>

完整版本的流程在这里:

<flow name="WS_name">
<http:listener path="someway/*" config-ref="External_Listener" doc:name="HTTP">
    <http:response statusCode="#[vars.httpStatus default 200]">
        <http:headers>#[vars.outboundHeaders default {}]</http:headers>
    </http:response>
    <http:error-response statusCode="#[vars.httpStatus default 500]">
        <http:body>#[payload]</http:body>
        <http:headers>#[vars.outboundHeaders default {}]</http:headers>
    </http:error-response>
</http:listener>
<http:request method="#[attributes.method]" sendBodyMode="AUTO" config-ref="HTTPS_Request_configuration_proxy" url="#['https://${endpoint.WS_name.host}:${endpoint.WS_name.port}' ++ '${endpoint.WS_name.path}/']">
    <http:headers>#[attributes.headers -- ["host", "http.headers"]]</http:headers>
</http:request>

如果有人有更好的解决方案,请分享。

1 个答案:

答案 0 :(得分:0)

您在做什么很好。如果要在http:request之外的流程中执行此操作,则可以。 http:headers期望的只是一张地图。因此,这是使用var的示例:

<set-variable variableName="myAttributes" value="#[attributes.headers -- ['host', 'http.headers']]" />

<http:request method="#[attributes.method]" sendBodyMode="AUTO" config-ref="HTTPS_Request_configuration_proxy"
            url="#['https://${endpoint.WS_name.host}:${endpoint.WS_name.port}' +++ '${endpoint.WS_name.path}/']">
            <http:headers>#[vars.myAttributes]</http:headers>
</http:request>