0
votes

I created a service where you call the mule service via http:

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8086" path="idnum" doc:name="HTTP"/>

so if you want to call this service you type:

http://localhost:8086/idnum

but what i want is for the http to accept an id number as a parameter and then store the id number into a variable so that i can use the id number. So the http would look like:

http://localhost:8086/idnum/4583948364094 for example.

So my question is how do you get the parameter from the url

2

2 Answers

4
votes

From Mule-3.6 on wards, we have HTTP Listener Connector, using which you can pass URI parameters.

You can access the URI parameters using the below MEL

#[message.inboundProperties.'http.uri.params'.id] provided your URI should be like this: http://localhost:8086/idnum/{id}

0
votes

You need to put the id as a message inbound parameter as following .. In Mule flow you need to do the following :-

<flow name="test">
    <http:inbound-endpoint exchange-pattern="request-response"
                           host="localhost" port="8086"
                           path="idnum" doc:name="HTTP"/>
    <!-- storing id in variable myId -->
    <set-variable variableName="myId"
                  value="#[message.inboundProperties['id']]" 
                  doc:name="Variable"/>
    <!-- Print the variable in console -->
    <logger level="INFO"  message="My id :- #[flowVars['myId']]"/>        
</flow>

Now in browser access

http://localhost:8086/idnum/?id=4583948364094

Now you can store it in a variable in Mule and you can see it in a logger like:

My id :- 4583948364094