簡體   English   中英

如何讀取mule esb中的參數

[英]How to read parameter in mule esb

我正在向 mule 發送一些參數,它正在通過 8081 中的 http 入站偵聽我正在發送。

http://localhost:8081/hey?age=manoj

但我不知道我怎么能把它當作消息? 我知道我可以從消息和有效負載訪問它,但是當我嘗試這樣做時

#[message payload: ['age']]

我收到錯誤,payload 是 String 類型,我對 mule 非常困惑。 我想要年齡值。

如果您使用的是 Mule 3.6 或更高版本,則表達式已更改..
所以現在,您需要以下表達式來獲取值:-

#[message.inboundProperties.'http.query.params'.age]

您可以在此處找到用於查詢的參考:- https://developer.mulesoft.com/docs/display/current/HTTP+Listener+Connector

這將作為入站財產進入。 您可以使用 MEL 訪問它:

<logger message="#[message.inboundProperties['age']]" level="INFO" doc:name="Logger"/>

盡管您需要確保在與 HTTP 入站端點相同的流中使用 inboundProperty,但請注意。

您可以通過入站屬性http.query.params檢索 HTTP 查詢參數。 要獲取年齡參數,請使用以下 MEL 表達式

#[message.inboundProperties.'http.query.params'.get('age')]

您需要使用 Mule HTTP Body to Param Map 轉換器,將 Params 轉換為 Map。

<http:body-to-parameter-map-transformer />      

然后為了訪問參數,要使用的 MEL 表達式是 #[payload['age']]

希望這可以幫助。

在 Mule 3.6 或 3.7 中,如果您在 mule 應用程序中使用Body to Parameter轉換器,則此功能已被棄用。 如果您需要訪問入站屬性值,您可以使用message.inboundProperties

#[message.inboundProperties.'http.query.params']

例子:

 <set-payload value="#[message.inboundProperties.'http.query.params']" doc:name="Set Payload"/>

如果你想在 groovy 腳本中使用它,請參考這個

使用 Groovy 獲取 ESB Mule 消息的入站屬性

這基本上告訴你可以將它用作

message.getInboundProperty('http.query.params')?.yourFantasticParam

或者

message.getInboundProperty('http.query.params')?.age

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM