Qlik Community

Ask a Question

QlikView Documents

QlikView documentation and resources.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY

Using EDX in QlikView 11 - basic example

Joe_Bickley
Employee
Employee

Using EDX in QlikView 11 - basic example

EDX is a trigger mechanism for starting a QlikView reload or task from an external source, such as a scheduler or application. To start a task using EDX the QlikView Management API must be used and this is delivered in the form of a Web Service.  The full details on EDX in QV 11 plus a detailed example and code is available here :  http://community.qlik.com/docs/DOC-2650

Below is a step by step simple example which may help you start to develop something for your own needs.  For this example you will require and need to be familiar with Visual Studio (the free version is fine, although the attached project is for Visual Studio 2010 pro) to write your application and you will need to under stand how to use QlikView management API. 

Step 1 - Create a task

First of all create the task you want to trigger, this can be any type of task and do this using the QlikView management account as normal.  For the task create a trigger, and for the type of trigger chose "On an external Event" and you need to specify a password that will be used to call the task (this isnt used anywhere else except for starting the task).  The below works both if you have a fully license Publisher but also if you just have server but the task creation screen in the QMC is slight different for each.

Step 2 - Create your application to us the API

We are going to use the QlikView management API to build an application that will start the task, the application itself could take any form such as web page with a button (like the attached) a command line app, a web service; whatever suits your business needs. The attached example is build as a .net web page with a button a user could click but the code can be lifted and moved to another application type. 

Its worth point out that this is the bare essentials for using EDX, it does not include things like task monitoring or error handling,  examples of more complex features can be seeing the above referenced document.

The attached project is pre-configured to use the QliKView Management API and below is just the code required to start a task,  refer to the documentation on how to get started with using the API as this can be a bit tricky to get used to.  I have used C# on a asp.net page and many examples will use this but you can use other languages and technologies also.

Open the attached project and you can review the key lines in the project by looking at the following:

First we will declare some variables we need to use,  the address of your QlikView server,  the name of your task (or its ID), and the password you specfied in the task.  Typically you would want to put these in a config file or allow them to be passed as parameters.

            string QMSURL = "http://localhost:4799/QMS/Service";

            string Taskname = "Reload of Golf Quest.qvw";

            string Taskpassword = "secret";

Second we will need to handle the Service Keys used to talk to the API, this needs to be done to call any function in the API, refer to docs for more details on this

            QMSClient Client;

            Client = new QMSClient("BasicHttpBinding_IQMS", QMSURL);

            string key = Client.GetTimeLimitedServiceKey();

            ServiceKeyClientMessageInspector.ServiceKey = key;

Finally the real part of the code example, calling the task.  It can be as simple as just one line as shown below or more complicated. 

            Client.TriggerEDXTask(new Guid("00000000-0000-0000-0000-000000000000"), Taskname, Taskpassword, "", new string[0]);

Breaking this line down the function "TriggerEDXTask" has 5 parameters

  1. The GUID of the QDS - this isthe identity of the reload component in QlikView, this might be the basic one attached to a server or a full Publisher, its actually the same service.  With publisher the GUID might be something different to the blank one above however the above line should work in both cases. If you have them on different servers, or more than one publisher you need to give the full and correct GUID.
  2. Taskname or GUID - fairly self explanatory the name of the task in the QMC, or its ID
  3. Task Password is the password you specified in the task
  4. Parameter name - When starting the task you can pass a variable into the reload script if needed, ive left it blank in this example
  5. Parameter values - the values for the above.

OK thats it, of course there is plenty more that could be done here but this is the basics. It is also possible to monitor the task for completion.

Step 3 Security & Running your code

To be allowed to request something from the API, the user or the code calling the function needs to run as an account with particular permissions.  These are windows permissions defined on the QlikView Server as two local groups, users must be in either the QlikView Administrators or QlikView EDX groups. The later of these is not created by default.

Depending on what type of application you build the way the users name gets to the Management Service can vary.  If the code is built into a windows exe file this will run as the user currently logged into windows. If it runs as a web page it will by default run as the identify of the application pool in IIS depending on it is set up and this might not be correct. 

The attached example uses imponsation, that is that the ID of the user logged into the web page will be passed along to the QlikView API.  You can see this being turn on in the web.config file with the line  <identity impersonate="true"/>.  IIS needs to be configured to allow this to work by requiring windows authentication on the page and for the application pool to run in classic mode.  In this scenario every user who might call the function needs to be in the groups mentioned above, while this is quite granular it might be administation you dont want to have. Also if the application is being called by a non-windows source such as a Unix based scheduler this may give issues.

An alternative is to modify the code so that a single user name is used to connect to the API on the behalf of all users, of course you needs to factor in some way of ensuring only permitted users can then use the application.  To do this modify the code as follows.

After the line Client = new QMSClient("BasicHttpBinding_IQMS", QMSURL); place the following lines

            WindowsClientCredential creds = Client.ClientCredentials.Windows;

            creds.ClientCredential.UserName = "myadminaccount";

            creds.ClientCredential.Password = "mypassword";

This will now call the API using the hardcoded credentials, although these should be saved in a config file.

Good luck and i hope this example helps

Labels (1)
Attachments
Comments
kkkumar82
Specialist III
Specialist III

Hi all,

Is there a way that EDX can be called from Java code from same machine or different remote machine.

Thanks

Kiran Kumar

0 Likes
Not applicable

Hi Joe,

Great example and potential solution to our issue (Re: Qlik AccessPoint Not Firing OnOpen Macro in QVW).  Marcus Sommer suggested your workaround.  Before I venture down the road of requesting access rights to our client's production environment to implement such a solution, is this the right/best fit for our issue?  Any guidance would be appreciated.  Thank you.

-Chris-

0 Likes
dutoitr
Partner
Partner

Hello Joe. These features you mentioned to are nice. Would you be kind enough to share the source code with me?

Joe Bickley wrote:

Hi Ralf,

Yes i have mocked up something as an example.  In Qlikview there is a simple extension object that just embeds any web page you want into a QVW.  I built a .net web page hosted it in IIS on my QlikView server and then displayed that page in my QVW via the extension object.

For my example i did a few extra things.  Firstly i made it so that a reload couldnt be started more often than every 15 minutes,  allowing users to trigger reloads is potentially dangerous as if 10 people do it at the same time its going to put pressure on the server and data sources and really it doesnt make sence to do it.   Secondly i made it so that only certain users would be able to hit the "reload" button on the webpage but no matter who you are you get to see if the reload is currently running or the time is last ran.

The example needs a bit of polish but i will try and send it to use via drop box in a personal message and publish a pucker one later.

Joe

0 Likes
adriano_fornoni
Contributor III
Contributor III

Thanks, it is useful

0 Likes
shovon_ra
Contributor II
Contributor II

Hi Joe,

Based on a requirement form one of my client for adhoc reloading, I spent a good amount of time with your code to make this working but no luck. I need a solution just like what you briefed here as exe based solution isnt an option for me. The issue is I am not getting any error to resolve when I click the button but it isn't actually reloading the document. It would be great help if you can give a clue or suggest where to find if there is anything I am missing. Please find below my code and configuration. thanks in advance.

Qlikview 11.20, Only QMC (No publisher)

Below picture is the Task on QMC : Password is same as set in the web.config file

/////////////////////////////////////////////////////////

C# Code :

string QMSURL = ConfigurationManager.AppSettings["QMSAPIURL"];

        string Taskname = ConfigurationManager.AppSettings["Taskname"];

        string Taskpassword = ConfigurationManager.AppSettings["Taskpassword"];

        void reloadviaEDX(string Taskname, string Taskpassword, string QMSURL)

        {

            // First of all connect to the QMS service and handle the service key

            Client = new QMSClient("BasicHttpBinding_IQMS", QMSURL);

            WindowsClientCredential creds = Client.ClientCredentials.Windows;

            creds.ClientCredential.UserName = "developer"; //[User is a member of both Qlikview EDX and Qlikview Management API groups]

            creds.ClientCredential.Password = "qlikdeveloper";

            //ServiceKeyEndpointBehavior serviceKeyEndpointBehavior = new ServiceKeyEndpointBehavior();

            //Client.Endpoint.Behaviors.Add(serviceKeyEndpointBehavior);

            string key = Client.GetTimeLimitedServiceKey();

            ServiceKeyClientMessageInspector.ServiceKey = key;

            //Trigger the task

            Client.TriggerEDXTask(new Guid("00000000-0000-0000-0000-000000000000"), Taskname, Taskpassword, "", new string[0]);

        }

///////////////////////////////////////////

Web Config File :

<?xml version="1.0"?>

<configuration>

  <system.web>

    <identity impersonate="true"/>

    <compilation debug="true"/>

  </system.web>

  <appSettings>

    <add key="QMSAPIURL" value="http://servername:4799/QMS/Service"/>

    <add key="Taskname" value="Reload of PAB.qvw"/>

    <add key="TaskPassword" value="123456"/>

  </appSettings>

  <system.serviceModel>

    <!-- Added for QMS API  -->

    <extensions>

      <behaviorExtensions>

        <add name="serviceKeyBehavior" type="EDXfromWebPage.ServiceSupport.ServiceKeyBehaviorExtensionElement, EDXfromWebPage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>

      </behaviorExtensions>

    </extensions>

    <behaviors>

      <endpointBehaviors>

        <behavior name="ServiceKeyEndpointBehavior">

          <serviceKeyBehavior/>

        </behavior>

      </endpointBehaviors>

    </behaviors>

    <!--  END Added for QMS API -->

    <bindings>

      <basicHttpBinding>

        <binding name="BasicHttpBinding_IQMS">

          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Ntlm"/>

          </security>

        </binding>

        <binding name="BasicHttpBinding_IQTService">

          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Ntlm"/>

          </security>

        </binding>

      </basicHttpBinding>

    </bindings>

    <client>

      <endpoint address="http://servername:4799/QMS/Service" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IQMS" contract="QMSBackendService.IQMS" name="BasicHttpBinding_IQMS" behaviorConfiguration="ServiceKeyEndpointBehavior"/>

    

    </client>

  </system.serviceModel>

</configuration>

0 Likes
megabyte23
Contributor III
Contributor III

I set up EDX and I am able to run it successfully under my login, but our production control department gets the error "Authorization failed for user domain\username".

I added her to the Qlik Admins group, per this piece of the instructions:

"These are windows permissions defined on the QlikView Server as two local groups, users must be in either the QlikView Administrators or QlikView EDX groups. The later of these is not created by default."

The error persists. I've thought about adding her onto every app we have- is that necessary? Any suggestions are appreciated.

0 Likes
vijay1kumar
Partner
Partner

Hi All,

I am going to use this service for triggering the Qlikview application after my ETL job gets completed.

and i want to use this as web service.

so just want to how i have to modify this script and where i ahve to keep this file and how i can call it once my ETL job completed .

it would you be greatful if you suggest some solution with step wise.

it is critical .

Thanks,

Vijay 

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2012-04-27 07:50 AM
Updated by: