Categories

Versions

You are viewing the RapidMiner Hub documentation for version 9.9 - Check here for latest version

Call web service from Qlik Sense

See also: Call web service from QlikView

This guide will walk you through the process of configuring and calling a RapidMiner AI Hub web service from your Qlik Sense environment:

  1. Open Qlik Sense and click on Create new app. On the popup window set the name and click on Create, the app will be created.
  2. Click the Open App button in the popup window.
  3. Click on the Navigation button on the left side and select Data load editor menu.
  4. On the Data load editor, click the Create new connection and select Web file. Set the URL and the name.

    Note: If the web service requires authentication, the URL has to be modified to include user credentials as follows: http://username:password@web-service-url

    Example: http://admin:pass123@dev.rapidminer.com:8080/api/rest/process/QlikSenseService?

  5. On the right side select the dataset by clicking on it. It will analyze the connection and give a preview of it. Select Html as File type and (based on your data) choose appropriate Field names and Character set. You can select and unselect attributes. Field names tell Qlik Sense where to look for column names. If the first record contains the names of columns then the Embedded field names setting should be selected. If the data does not contain column names, No field names should be selected. RapidMiner always sends column names as first record so Embedded Labels is the setting to use.
  6. Press the Insert script and it will put the script to the main data management page. Qlik Sense will automatically create a data loading script.
  7. When the Data load button is clicked on the right side, Qlik Sense will call the RapidMiner web service and RapidMiner AI Hub will execute the process behind the web service. Depending on the complexity of your process and the amount of data, this step can take some time. Once RapidMiner AI Hub has executed the process and all data is received by Qlik Sense, a new window will open.
  8. The data is now in Qlik Sense and ready to use. Click Navigation button again and select App overview. Here you can add new sheet and create a dashboard.
  9. Now that the two tools have been connected and data is pulled from RapidMiner AI Hub to Qlik Sense, data can be used to build dashboards. Data can also be refreshed on demand by going to the Navigation button on the left side and select Data load editor menu. Once the editor is opened click Load Data on the top right corner. On data reload, the script will call the RapidMiner web service again and receive fresh data back.

Call Parameterized Web Service

It is possible to configure a RapidMiner AI Hub web service to accept URL query parameters. Qlik Sense offers two ways by which a parameterized web service can be called:

Before being able to exploit these features Qlik Sense requires some initial configuration.

Qlik Sense Configuration

To be able to call an external web service with dynamic parameters, Qlik Sense must be configured to allow the data loading script lib reference to be replaced by the actual URL as well as two specific extensions need to be installed.

Using URL references

By default Qlik Sense replaces the URL with which a data connection was setup with a lib reference in the data loading script

To change this behavior the Settings.ini file needs to be changed to enable Legacy Mode. This is done by setting the StandardReload variable value to 0
The Settings.ini file can be usually found in two locations:

  • C:\Users\{user-name}\Documents\Qlik\Sense
  • C:\Users\{user-name}\AppData\Local\Programs\Qlik\Sense\

If the file is present in both locations then you need to update it twice, once for each location.

Qlik Sense Extensions

Qlik Sense Extensions can be added to Qlik Sense by copying them to the C:\Users\{user-name}\Documents\Qlik\Sense\Extensions folder. For this guide the necessary extensions that need to be installed are the following:

Using Data Loading Script

Parameters are passed through the URL of the web service. To be able to pass parameters, the data loading script has to be modified.

  1. Open Data load editor page from Navigation menu.
  2. Locate the URL of web service and add parameters to URL, by clicking on the Edit Connection option or by copying the URL directly to the script replacing the “lib://“ statement and edit the script.

    Be sure to add the URL within the square brackets, if you remove them the data loading script will fail

    Parameters are added to the end of the web services URL preceded by a question mark (?).
    Syntax: http://username:password@web-service-url?param-name=value

    Example: http://admin:pass123@dev.rapidminer.com:8080/api/rest/process/QlikService?p0=1

  3. Save the script by pressing CTRL + S or going to File > Save.
  4. Reload the script by pressing the Load Data.

Using Qlik Sense Variables

To be able to pass Qlik Sense variables as parameters to a RapidMiner web service, variables have to be defined in Qlik Sense and a data load script modified to use them.

  1. To create Qlik Sense Variable go to Edit on the dashboard sheet and select the Variables button on the left bottom. The following window will pop up.
  2. Click on Create new button, fill it and click on the save button at the top right corner.
  3. The new variable will appear on Variables window.
  4. Create new Variable object on Qlik Sense dashboard (or use existing). Such objects can be created once the Variable extension has been installed to Qlik Sense.
  5. Select the object and on the right side there is the Appearance panel.
  6. Setup the variable name, style and other settings in the Variable menu.
  7. To add values click on Add Alternative and add the desired value and the label that you would like to use.
  8. Create a Sheet Navigation & Action object on the dashboard. Such objects can be created once the Sense Navigation extension has been installed to Qlik Sense.
  9. In Actions menu in the properties window on the right enable the Actions before Navigation option.
  10. Select Set Variable Value from the First Action dropdown list and add the Variable Name.
  11. Click on the Navigation button on the left side and select Data load editor menu
  12. Locate the URL of the web service and add parameters to the URL. Parameters are added to the end of the web services URL preceded by ? (question mark).

    Parameters are appended to the end of a web service URL string, preceded by a question mark (?).
    URL syntax: http://username:password@web-service-url?param-name=value
    Qlik Sense variables can be referenced with the following syntax: $(variable-name)

    Example: http://admin:pass123@dev.rapidminer.com:8080/api/rest/process/QlikSenseService?p0=$(Variable1)

  13. Save the script by pressing CTRL + S or the Save button.
  14. Reload the script by pressing the Load Data button.
  15. Data will be reloaded with parameter value equal to variable value.
  16. You can also add a Reload button to the dashboard directly allowing users to load data easier.
  17. After adding the Qlik Sense Reload Button extension to the appropriate directory (Documents/Qlik/Sense/Extensions) add the Reload Btn object to the dashboard.