(MODS:我查過我相似的其他線程,但這個問題是在更深的層次)騾子ESB:不能將傳入的JSON對象,通過「選擇」節點
我轉換一個Hello World流向接受JSON對象的流,我試圖使用'Choice'流控制節點將它路由到兩個'Set Payload'節點之一。
我的問題是我能得到的流量選擇節點路由到正確的目的地節點
(我懷疑這是一個JSON問題)
下面是我的流程
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:json="http://www.mulesoft.org/schema/mule/json" version="EE-3.5.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<json:object-to-json-transformer name="Object_to_JSON" doc:name="Object to JSON"/>
<flow doc:name="HelloWorldFlow1" name="HelloWorldFlow1">
<http:inbound-endpoint doc:description="This endpoint receives an HTTP message." doc:name="HTTP" exchange-pattern="request-response" host="localhost" port="8081" contentType="application/json"/>
<choice doc:name="Choice-Determine-Route" tracking:enable-default-events="true">
<when expression="#[payload.uid == 'ABC']">
<set-payload value="#['When ABC case']" doc:name="Set Payload"/>
</when>
<otherwise>
<set-payload value="#['Default case, uid: ' + payload.uid + ', payload: ' + payload]" doc:name="Set Payload"/>
</otherwise>
</choice>
</flow>
</mule>
我正在發送以下JSON字符串流
{ "uid" : "ABC" }
所以流量應該能夠檢測到UID等於「ABC」
下面是我的測試程序
C:\curl>curl -H "Content-Type: application/json" -i -d @input2.txt http://localh
ost:8081
HTTP/1.1 200 OK
Date: Tue, 15 Jul 2014 09:42:34 -0700
Server: Mule EE Core Extensions/3.5.0
Content-Type: application/json
X-MULE_SESSION: rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW
7GGKAwAFWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxv
d0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wACnByb3BlcnRpZXN0AA9MamF2YS91
dGlsL01hcDtMAA9zZWN1cml0eUNvbnRleHR0ACdMb3JnL211bGUvYXBpL3NlY3VyaXR5L1NlY3VyaXR5
Q29udGV4dDt4cAFwdAAkMDU2OTdkYjEtMGMzZi0xMWU0LWExYjEtMDAyMTVlNmIzZDkwc3IAJWphdmEu
dXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW1xAH4AA0wABW11dGV4
dAASTGphdmEvbGFuZy9PYmplY3Q7eHBzcgAkb3JnLm11bGUudXRpbC5DYXNlSW5zZW5zaXRpdmVIYXNo
TWFwndHZ72dFzgADAAB4cHcMP0AAAAAAABAAAAAAeHEAfgAJeHB4
X-MULE_ENCODING: UTF-8
Content-Length: 99
Connection: close
Default case, uid: null, payload: org.apache.commons.httpclient.ContentLengthI
[email protected]
正如你所看到的,我送「ABC」的UID,但它還是到默認情況
,你可以在流中看到的,我打印出「設置有效載荷」節點相關的有效載荷信息:
#[「默認情況下,UID:」 + payload.uid +」,有效載荷: '+有效載荷]
......,正如你可以從測試程序我從該聲明以下輸出看到:
Default case, uid: null, payload: org.apache.commons.httpclient.ContentLengthI
[email protected]
2個問題
我怎樣才能解決這個,所以我可以打「ABC '路線?
-
我知道它的輸入流,但如果是數據?
感謝