Template Syntax

Use

Templates are used to determine the content of a character string at runtime, based on the values of the input variables used.

You can create templates for the following objects:

  • MQTT source system

    You can create a template on the Tag Definition tab by choosing the button Configure Message from Template and entering a character string in the dialog box that then appears. This is only possible in conjunction with the payload types JSON and Formatted String.

    When you make your entries in the dialog box, the parameters in the Message Configuration table and the Tag List are updated automatically in the MQTT source system. The four buttons that are used for entering and removing tags (below the table) are inactive when you enter the tags in the dialog box.

  • Universal Web service destination system

    You can create a template at the following places:

    • On the Templates tab

    • By choosing the button Configure Message from Template on the Operation Configuration tab. You use this button to automate the configuration of a request message for a RESTful service if you use the JSON payload type.

    • In the endpoint URI of a RESTful service

    • On the Advanced Configuration tab (on the Operation Configuration tab). You can enter header names and values in the Headers screen area. These header values are then adopted on the Request Message Configuration tab as input variables.

Structure of a Template

Each template contains a sequence of literal values and placeholders. The placeholders are displayed with curly brackets and have the following syntax:

{<variable name> [:<variable type>]}.

The variable name must be valid, that is, it must start with a letter and must only contain numbers and letters. The variable type is optional and can be omitted. In this case, the assumption is that the variable type is a String. You can specify each of the primitive data types allowed for Web services. You can specify each of the primitive data types allowed for Web services. You can find a list of permitted data types under Add a Request or Response Mapping.

If you want to add curly brackets in the payload, you need to use escape characters: '{' is an escape character for '{' and '}' is an escape character for '}'.