【问题标题】:How do I force the HTTP Request Connector to use a certain Content-Type?如何强制 HTTP 请求连接器使用某个 Content-Type?
【发布时间】:2015-04-28 09:45:21
【问题描述】:

在 Mule 3.6 中,我有以下 HTTP 请求连接器:

<http:request config-ref="IPAM_Request_Config" path="${ipam.path}" method="POST" doc:name="Send SMS to IPAM">
    <http:request-builder>
        <http:query-param paramName="mobile" value="sms.mobile"/>
        <http:query-param paramName="textmsg" value="sms.text"/>
        <http:query-param paramName="receiver" value="sms.receiver"/>
        <http:query-param paramName="mobileoperator" value="sms.operator"/>
        <http:query-param paramName="circle" value="sms.circle"/>
        <http:query-param paramName="time" value="sms.time"/>
    </http:request-builder>
</http:request>

如何强制将Content-Type 设为application/x-www-form-urlencoded。即使有效负载是org.mule.module.http.internal.ParameterMap,它也会占用text/plain;charset=windows-1252

【问题讨论】:

    标签: java http mule


    【解决方案1】:

    在请求之前手动设置 Content-Type:

    <set-property propertyName="Content-Type" value="application/x-www-form-urlencoded" />
    

    【讨论】:

      【解决方案2】:

      您也可以在 http:request-builder 中使用以下内容进行设置:

      <http:request-builder>
          <http:query-param paramName="mobile" value="sms.mobile"/>
          ... other params ....
          <http:header headerName="Content-Type" value="application/x-www-form-urlencoded"/>
      </http:request-builder>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-02-12
        • 1970-01-01
        • 2014-05-24
        • 2021-10-17
        • 1970-01-01
        • 2013-06-03
        • 2021-06-19
        相关资源
        最近更新 更多