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
Pass the payload value in Setpayload as a Request:
[
{
"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
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
URL: http://0.0.0.0:8081/parse Method: POST
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.
Leave a Comment