Categories: Mule 4Mulesoft

Parse Template Reference in Mule4

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

FieldValueDescription
Display NameParse TemplateCustomize to display a unique name for the transformer in your application.
LocationfilepathDefine 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.

Instagram

Facebook

Recent Posts

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

1 year ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

1 year ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

1 year ago

Binary Search Tree (BST)

A Binary Search Tree (BST) is a type of binary tree that satisfies the following…

1 year ago