Contact Free trial Login

Parse Template Reference

MuleSoft recommends against deployments to Mule 3.8. Standard Support for this version ended on November 16, 2018, and Mule 3.8 will reach its End of Life on November 16, 2021, when Extended Support ends.

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.

For example, perhaps you want a Mule flow to send an "order complete" HTTP response to a caller to indicate the new order’s number and the number of widgets ordered (both values that you previously set on the Mule message as variables). You can use a parse template to load a file from an external location – a file which, behaving as a template, expects values for "order number" and "number of widgets". Then, the parse template extracts info from the Mule message variables to insert as values into the template and set the resulting contents as the message payload. In essence, a parse template pulls a template file into a Mule flow, fills in the blanks, then sets results on the message as the payload. In the example, after the parse template sets the payload on the message using the external file as a template, the Mule flow returns the HTTP response to confirm the order.

Configuring a Parse Template

Studio Visual Editor

Drag a parse template message processor from the palette onto the canvas, then configure the fields according to the table below.

Field Value Description

Display Name

Parse Template

Customize to display a unique name for the transformer in your application.



Define the location of the file that Mule uses as a template into which to insert values extracted from the message properties or variables.

XML Editor or Standalone

Add a parse-template element to your flow, then configure according to the tables below.

<parse-template location="users/administrator/desktop/hrweb/confirmation.html" doc:name="Parse Template"/>

Attributes of the parse-template element:

Element Attributes Value


Filepath which defines the location of the file that Mule uses as a template into which to insert values extracted from the message properties or variables.


Customize to display a unique name for the transformer in your application. (Note: Not needed in Mule standalone.)

Complete Code Example

The following example demonstrates the use of a parse template in an application which accepts queries by employeeID in order to acquire data about an employee.

The parse template uses a flow-external file as a template into which it inserts values for fields – name, department, job title, start date, and employee type – drawn from the message payload. The flow then returns the template-built payload to the caller.

parse template flow
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="" xmlns:jdbc-ee="" xmlns:http="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation="">

    <jdbc-ee:mssql-data-source name="MySQL_Data_Source" user="user" password="pw" url="jdbc:mysql://localhost:3306/hrDB" transactionIsolation="UNSPECIFIED" doc:name="MS SQL Data Source"/>

    <jdbc-ee:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
          <jdbc-ee:query key="getEmployeeById" value="SELECT * FROM Employees WHERE id=#[message.inboundProperties.'http.query.params'.id]"/>

    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" basePath="getEmployee" doc:name="HTTP Listener Configuration"/>
    <flow name="exampleTemplateFlow1" >
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"  doc:description="Send GET request with a parameter, for example, http://localhost:8081/getEmployee?id=12345"/>
        <jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="getEmployeeById" queryTimeout="-1" connector-ref="Database" doc:name="Database" doc:description="Returns list of maps containing records; only the first one is required."/>
        <parse-template location="src/test/resources/responseHtml.template" doc:name="Parse Template"/>
        <set-property doc:name="Content Type" propertyName="Content-Type" value="text/html"/>

To use the application in this example, you must send an HTTP request with a URL that includes an ID query parameter, such as http://localhost:8081/getEmployee?id=12345.

See Also

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub