Manoj Singh
Manoj Singh

Reputation: 951

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.

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. I want age value.

Upvotes: 4

Views: 6789

Answers (6)

In Mule 3.6 or 3.7, if you been using the Body to Parameter transformer in your mule applications, this has been deprecated. If you need to access the inbound properties values, you can do that using message.inboundProperties.

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

Example:

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

Upvotes: 0

mcvkr
mcvkr

Reputation: 3912

If you want to use it in a groovy script please refer to this

getting inbound properties of ESB Mule message using Groovy

which basically tells you can use it as

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

or

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

Upvotes: 0

Anirban Sen Chowdhary
Anirban Sen Chowdhary

Reputation: 8311

If you are using Mule 3.6 version or above, the expression has been changed ..
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

Upvotes: 7

Nuno
Nuno

Reputation: 496

You can retrieve the HTTP query parameters through the inbound property http.query.params. To obtain the age parameter, use the following MEL expression

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

Upvotes: 1

Jameson Triplett
Jameson Triplett

Reputation: 96

This will come in as an inbound property. You can access it using 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.

Upvotes: 1

user1760178
user1760178

Reputation: 6657

You need to use Mule HTTP Body to Param Map transformer, to convert the Params to a Map.

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

Then inorder to access the parameter the MEL expression to be used is #[payload['age']]

Hope this helps.

Upvotes: 0

Related Questions