2015-10-06 61 views
0

我有一個Mule流,它在Mule CE3.6.1中使用HTTP請求端點。它需要使用編碼的HTTP URL來獲取正確的數據。Mule CE 3.6.1 HTTP請求URL編碼問題

請注意編碼的網址:/items?q=%2Blabel%3ABOTV2309H*%20%2Bparent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F* &行= 100 & start = 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> 

當騾子流運行,這裏被請求的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端點的問題嗎?

謝謝!

+0

找到別人發佈了類似的問題。 http://forums.mulesoft.com/questions/30380/plus-sign-in-http-url.html –

回答

0

我將參數分爲查詢和uri參數。然後這個問題得到解決。

<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>