从 request-config 中删除 headers 而不是 MULE 4 中的流

Deleting headers from request-config instead of flow in MULE 4

我正在尝试通过比实际更有效的方式找到在 MULE 4 中删除请求 headers 的解决方案。 在请求配置中可能有 <http:default-headers />,但我找不到从这里删除 headers 的方法。所以我要删除流程中的 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>

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

你做的很好。如果你想在 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>