Overviews
The Parse Template component loads a file into the Mule payload. The ‘Parse Template’ transformer parses a template file that can contain Mule Expression Language and places the resulting string into the message payload. Use a parse template to load the content of a flow-external file into a Mule flow, then use the file as a template into which you can insert data returned as the result of evaluated Mule expressions.
Parse Template
Parse Template is the Mule component to use for processing a template and obtaining a result. A template is defined as text with embedded Mule expressions that are evaluated and replaced with their result.
Studio Visual Editor
General configuration of HTTP Listener
![](https://coderzpy.com/wp-content/uploads/2022/01/image-1-1024x303.png)
Pass the payload value in Setpayload as a Request:
![](https://coderzpy.com/wp-content/uploads/2022/01/image-2-1024x483.png)
[
{
"orderNumber": "343543",
"orderStatus": "Active",
"orderDate": "2022-01-01",
"orderDescription": "2 laptop ordered"
},
{
"orderNumber": "343893",
"orderStatus": "Active",
"orderDate": "2022-01-08",
"orderDescription": "2 laptop ordered"
},
{
"orderNumber": "345443",
"orderStatus": "Active",
"orderDate": "2022-01-06",
"orderDescription": "2 laptop ordered"
}
]
Drag a parse template message processor from the palette onto the canvas, then configure the fields according to the table below.
File location: C:\Users\mhsar\OneDrive\Desktop\order.hml.txt
![](https://coderzpy.com/wp-content/uploads/2022/01/image-5.png)
![](https://coderzpy.com/wp-content/uploads/2022/01/image-3-1024x593.png)
Field | Value | Description |
---|---|---|
Display Name | Parse Template | Customize to display a unique name for the transformer in your application. |
Location | filepath | Define the location of the file that Mule uses as a template into which to insert values extracted from the message properties or variables. |
Add a logger which will print the received payload in Console
![](https://coderzpy.com/wp-content/uploads/2022/01/image-4-1024x581.png)
URL: http://0.0.0.0:8081/parse Method: POST
![](https://coderzpy.com/wp-content/uploads/2022/01/image-6-1024x175.png)
Response:
<html>
<table border=2>
<tr>
<th>order Number</th>
<th>order Status</th>
<th>order Date</th>
<th>order Description</th>
</tr>
<tr>
<td>343543</td>
<td>Active</td>
<td>2022-01-01</td>
<td>2 laptop ordered</td>
</tr>
<tr>
<td>343893</td>
<td>Active</td>
<td>2022-01-08</td>
<td>2 laptop ordered</td>
</tr>
<tr>
<td>345443</td>
<td>Active</td>
<td>2022-01-06</td>
<td>2 laptop ordered</td>
</tr>
</table>
<html>
Follow Me
If you like my post please follow me to read my latest post on programming and technology.
![](http://coderzpy.com/wp-content/uploads/2022/02/20220121_231213-scaled-e1643999591962.jpg)