简体   繁体   English

如何读取mule esb中的参数

[英]How to read parameter in mule esb

I am sending some parameter to mule which is listening through http inbound in 8081 I am sending.我正在向 mule 发送一些参数,它正在通过 8081 中的 http 入站侦听我正在发送。

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

But I don't know How can I take this as from message??但我不知道我怎么能把它当作消息? I know I can access it from message and payload but when I try to do this我知道我可以从消息和有效负载访问它,但是当我尝试这样做时

#[message payload: ['age']]

I am getting error that payload is a String type and I am very much confuse in mule.我收到错误,payload 是 String 类型,我对 mule 非常困惑。 I want age value.我想要年龄值。

If you are using Mule 3.6 version or above, the expression has been changed ..如果您使用的是 Mule 3.6 或更高版本,则表达式已更改..
So now, you need the following expression to get the value :-所以现在,您需要以下表达式来获取值:-

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

You can find the reference here for you query :- https://developer.mulesoft.com/docs/display/current/HTTP+Listener+Connector您可以在此处找到用于查询的参考:- https://developer.mulesoft.com/docs/display/current/HTTP+Listener+Connector

This will come in as an inbound property.这将作为入站财产进入。 You can access it using MEL:您可以使用 MEL 访问它:

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

Be careful though you need to make sure to use the inboundProperty in the same flow as your HTTP Inbound endpoint.尽管您需要确保在与 HTTP 入站端点相同的流中使用 inboundProperty,但请注意。

You can retrieve the HTTP query parameters through the inbound property http.query.params .您可以通过入站属性http.query.params检索 HTTP 查询参数。 To obtain the age parameter, use the following MEL expression要获取年龄参数,请使用以下 MEL 表达式

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

You need to use Mule HTTP Body to Param Map transformer, to convert the Params to a Map.您需要使用 Mule HTTP Body to Param Map 转换器,将 Params 转换为 Map。

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

Then inorder to access the parameter the MEL expression to be used is #[payload['age']]然后为了访问参数,要使用的 MEL 表达式是 #[payload['age']]

Hope this helps.希望这可以帮助。

In Mule 3.6 or 3.7, if you been using the Body to Parameter transformer in your mule applications, this has been deprecated.在 Mule 3.6 或 3.7 中,如果您在 mule 应用程序中使用Body to Parameter转换器,则此功能已被弃用。 If you need to access the inbound properties values, you can do that using message.inboundProperties .如果您需要访问入站属性值,您可以使用message.inboundProperties

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

Example:例子:

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

If you want to use it in a groovy script please refer to this如果你想在 groovy 脚本中使用它,请参考这个

getting inbound properties of ESB Mule message using Groovy 使用 Groovy 获取 ESB Mule 消息的入站属性

which basically tells you can use it as这基本上告诉你可以将它用作

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

or或者

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM