<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:tls="http://www.mulesoft.org/schema/mule/tls" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd">
<data-mapper:config name="new_mapping_grf" transformationGraphPath="new_mapping.grf" doc:name="DataMapper"/>
<data-mapper:config name="map_to_csv" transformationGraphPath="map_to_csv.grf" doc:name="map_to_csv"/>
<!-- Necessary configuration element used by all examples -->
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<!-- Example 1 Start How to access properties using MEL, how to set a payload dynamically -->
<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>
<!-- Example 1 End -->
<!-- Example 2 Start How to dynamically route messages based on the results of a conditional expression -->
<flow name="greetingFlow2" >
<http:listener config-ref="HTTP_Listener_Configuration" path="greet2" doc:name="HTTP"/>
<choice doc:name="Choice">
<when expression="#[message.inboundProperties.'http.query.params'.username == empty]">
<set-payload value="#['No username provided']" doc:name="Set Payload for invalid username"/>
</when>
<otherwise>
<set-payload value="Hello #[message.inboundProperties.'http.query.params'.username]" doc:name="Set Payload for valid username"/>
</otherwise>
</choice>
</flow>
<!-- Example 2 End -->
<!-- Example 3 Start How to assign variables, how to evaluate a condition -->
<flow name="greetingFlow3" >
<http:listener config-ref="HTTP_Listener_Configuration" path="greet3" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[flowVars.username = message.inboundProperties.'http.query.params'.username]]></expression-component>
<set-payload value="#[message.inboundProperties.'http.query.params'.username], #[message.inboundProperties.'http.query.params'.age], #[message.inboundProperties.'http.query.params'.age >18]" doc:name="Set Payload"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars.username]" doc:name="Set Payload"/>
</flow>
<!-- Example 3 End -->
<!-- Example 4 Start How to create a map, how to evaluate a condition with DataMapper -->
<flow name="greetingFlow4" >
<http:listener config-ref="HTTP_Listener_Configuration" path="greet4" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[flowVars.username = message.inboundProperties.'http.query.params'.username]]></expression-component>
<set-payload value="#[['username' : message.inboundProperties.'http.query.params'.username, 'age' : message.inboundProperties.'http.query.params'.age]]" doc:name="Set Payload"/>
<data-mapper:transform config-ref="Map_To_CSV" doc:name="Map To CSV"/>
<file:outbound-endpoint path="path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars.username]" doc:name="Set Payload"/>
</flow>
<!-- Example 4 End -->
<!-- Example 5 Start How to parse XML input with Xpath -->
<flow name="docs-greetingFlow5" doc:name="greetingFlow5">
<http:listener config-ref="HTTP_Listener_Configuration" path="greet5" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[flowVars.username = xpath3('/user/username').text]]></expression-component>
<set-payload value="#[xpath3('/user/username').text], #[xpath3('/user/age').text], #[xpath3('/user/age').text > 18]" doc:name="Set Payload"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars.username]" doc:name="Set Payload"/>
</flow>
<!-- Example 5 End -->
<!-- Example 6 Start How to parse Java objects -->
<flow name="greetingFlow6" doc:name="greetingFlow6">
<http:listener config-ref="HTTP_Listener_Configuration" path="greet6" doc:name="HTTP"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.lang.Object"/>
<expression-component doc:name="Expression"><![CDATA[flowVars.username = payload.username]]></expression-component>
<set-payload value="#[payload.username], #[payload.age], #[payload.age > 18]" doc:name="Set Payload"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars.username]" doc:name="Set Payload"/>
</flow>
<!-- Example 6 End -->
</mule>