Studio Visual Editor
-
In a new flow, drag an HTTP connector and a Set Payload transformer.
-
Open the HTTP connector’s properties editor and give it the path
greet1
. Then create a Connector Configuration element for it and set its host tolocalhost
and port to8081
. In this way, the connector can be reached via the URIhttp://localhost:8081/greet1
-
Open the Set Payload’s properties editor and set the value field with the following MEL expression:
Hello #[message.inboundProperties.'http.query.params'.username]
This expression captures the inbound property "username", which is passed as a query string parameter when calling the service.
-
Save and run the project.
-
Through a web browser, access the URL
http://localhost:8081/greet1?username=yourName
The response prints the wordsHello yourName
in your browser.
XML Editor
-
In a new flow, add an
http:listener
and configure it with the pathgreet1
.<http:listener config-ref="HTTP_Listener_Configuration" path="greet1" doc:name="HTTP"/>
Attribute Value config-ref
HTTP_Listener_Configuration
path
greet1
doc:name
HTTP
In this way, the connector is reached via the URI
http://localhost:8081/greet1
. -
Create a Connector Configuration element for it with a name that matches the referenced element in
config-ref
. Set the Port to 8081 and the Path tolocalhost
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
Attribute Value name
HTTP_Listener_Configuration
host
--- localhost
port
8081
path
greet1
doc:name
HTTP_Listener_Configuration
-
After the connector, add a
set-payload
transformer, configured as shown:<set-payload value="Hello #[message.inboundProperties.'http.query.params'.username]" doc:name="Set Payload"/>
Attribute Value value
Hello #[message.inboundProperties.'http.query.params'.username]
doc:name
Set Payload
The MEL expression used in
value
captures the inbound propertyusername
, which is passed as a query string parameter when calling the service. -
The full code of your flow should look like this:
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/> <flow name="greetingFlow1" doc:name="greetingFlow1"> <http:listener config-ref="HTTP_Listener_Configuration" path="greet1" doc:name="HTTP"/> <set-payload value="Hello #[message.inboundProperties.'http.query.params'.username]" doc:name="Set Payload"/> </flow>
-
Save and run the project.
-
Through a browser, access the URL` http://localhost:8081/greet1?username=yourName `
This displays the wordsHello yourName
in your browser.