Mule CE 3.6.1 HTTP请求URL编码问题

时间:2015-10-06 14:47:57

标签: http encoding mule

我有一个Mule流程,它在Mule CE3.6.1中使用HTTP Request端点。它需要使用编码的HTTP URL来获取正确的数据。

请注意编码的网址:/items?q=%2Blabel%3ABOTV2309H*%20%2Bparent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F*&rows=100&开始= 0

这是测试流程。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8089" basePath="/" usePersistentConnections="false" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Config_Search" host="testserver" port="80" basePath="/index" usePersistentConnections="false" doc:name="HTTP Request Configuration"/>
<flow name="testFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="*" allowedMethods="POST" doc:name="HTTP"/>
    <object-to-string-transformer doc:name="Object to String"/>
    <logger level="INFO" doc:name="Logger"/>


    <http:request config-ref="HTTP_Request_Config_Search" path="/items?q=%2Blabel%3ABOTV2309H*%20%2Bparent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F*&amp;rows=100&amp;start=0" method="GET" doc:name="HTTP"/>
    <logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>

当Mule流程运行时,这里是请求的URL(通过wireshark找到):

/items?q=%20label%3ABOTV2309H%2A%20%20parent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F%2A&rows=100&start=0

请注意%2B在两个地方被%20取代,显然不会返回我需要的数据。

这是HTTP端点的问题吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

我将params分为查询和uri params。然后这个问题得到了解决。

<http:request config-ref="HTTP_Request_Config_Search" path="/items" method="GET" doc:name="HTTP">
        <http:request-builder>
            <http:query-param paramName="q" value="+label:BOTV2309H* +parent.uri:\/test\/gateway\/*"/>
            <http:uri-param paramName="rows" value="100"/>
            <http:uri-param paramName="start" value="0"/>
        </http:request-builder>
    </http:request>