Create web service data sources

The data source input screen opens, in which you can select the web service data source as “Type” as the first step.

However, if you first assign a name to the data source and it contains the word “webservice“, “Webservice” is already preselected as the data source type. (This works with all data source types)

Once this has been done, the data source-specific settings of the web service data source are automatically adjusted.

Web service specific

The web service data source is used to exchange information with a web service.

Data must be transferred in “JSON“, “XML” or “URLEncoded” format.


Read:

  • Request method

Some web services expect certain request methods for reading data.

Here you determine the request method for reading the data source.

The request methods “GET” and “POST” are available here.

  • URL

The URL that is called up to read data from the web service.

The use of placeholders (see below) is permitted.

  • Parameters

Additional parameters that are to be transferred to the web service together with the read request.

Supported formats here are also “JSON“, “XML” and “URLEncoded“. The use of placeholders (see below) is permitted.

To enlarge the input field so that you can write better, use the magnifying glass icon next to the text field.


Writing:

  • Request method

Some web services expect certain request methods for writing data. Here you determine the request method for writing the data source. The request methods “GET“, “POST” and “PUT” are available here.

  • URL

The URL that is called up to send data to the web service (writing variables). If no different write URL is specified, the read URL is also called for writing. The use of placeholders (see below) is permitted.

If problems occur when processing the data in the web service, this can be reported to the QuickHMI system so that it can display a corresponding error message. The response from the server is expected in a specific format.

Response examples in the 3 supported formats can be found below. As soon as the transmitted quality deviates from “GOOD“, an error message is displayed in QuickHMI with a corresponding message.

Example of the “URLEncoded” format:

quality=XXXXXXXX&message=XXXXXX

Example of the “JSON” format:

{
"quality": "XXXXXX",
"message": "XXXXXX"
}

Example of the “XML” format:

<response>
<quality>XXXXXX</quality>
<message>XXXXXX</message>
</response>
  • Parameters

Parameters that are sent to the web service together with a write request.

By using placeholders (see below), the variable to be written and the value to be written can be transferred.

Examples of possible parameters for the individual formats can be found below.

To enlarge the input field so that you can write better, use the magnifying glass icon next to the text field.

Example of the “URLEncoded” format:

path=@var_path@value=@var_value

Example of the “JSON” format.

{
"path": "@var_path",
"value": "@var_value"
}

Example of the “XML” format:

<?xml version= "1.0"?>
<write_request>
       <path>@var_path</path>
       <value@var_value</value>
</write_request>

If the data source is also to be used for writing, you must implement this logic on the web server accordingly.
QuickHMI only calls up the defined URL with the defined parameters.

  • Headers

In this area, http headers can be defined.

New headers can be created using the plus button. To do this, assign a header name and a header value.

You can create your own headers or choose from a variety of predefined standards.

Several headers can be created with “Add” and deleted again with the “X“.

The Authorization Header:

Some URLs require authentication via user name and password when they are called up. The Authorization header is used for this purpose.

If you select this, a key icon appears, which opens a new window. Here you can enter the login data expected by the server.

After subsequent confirmation with “OK“, the value field for the header is filled in automatically. The content for the Authorization Header can therefore be generated automatically by entering the user name and password. However, this is optional and can also be filled in manually.

Placeholder:

Placeholders can be used in the URLs and parameters to call up variable-specific URLs or send variable-specific parameters.

The following placeholders are available:

  • @var_name

Contains the name of the variable in the QuickHMI system.

  • @var_path

Contains the path within the “JSON” or “XML” structure. In the case of “URLEncoded” data, only the key is included.

  • @var_value (Only for write requests)

Contains the value to be written.

By using placeholders in the read URL or the read parameters, a separate request is sent to the web server for each variable.

With many variables, the use of such placeholders can lead to performance losses. There is no such restriction when writing, as a single request is sent for each variable anyway, regardless of the use of placeholders.


After entering the relevant information for the connection, click on “Add” or on “Save” after editing an already created data source.

The web service data source is created and subsequently displayed in the data source overview.

Created data sources can be edited or deleted again. You can do this using the corresponding buttons.

You also have the option of displaying all internal data sources.

This works by activating the “Show internal data sources” checkbox.


You can find out how to add variables for the web service data source in the chapter “Adding web service variables“.