如何强制HTTP请求连接器使用某种内容类型?

时间:2015-02-26 05:41:36

标签: java http mule

在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。即使有效负载为text/plain;charset=windows-1252,也需要org.mule.module.http.internal.ParameterMap

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

您还可以使用以下内容在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>