4
votes

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.

6
COuld you share the actual error message?Rohit

6 Answers

7
votes

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

1
votes

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.

1
votes

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')]
0
votes

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.

0
votes

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

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