Running Custom MicroStrategy Visualizations on the iPad: Part 2

Last month, I posted about some exciting new features in Flash Builder 4.5 that allowed us to port existing Flash visualizations directly to the iPad without any major code modifications.  One of the issues I previously hadn’t worked out (and admittedly, the most important feature) was the ability for the iPad version of the visualization to pull data directly from MicroStrategy at runtime.

I’m happy to report that I’ve got past those roadblocks and now have a MicroStrategy Visualization running natively on the iPad and pulling data directly from our MicroStrategy server!  Today, I’ll show you how.

Before continuing, make sure that you check out the original post:

Running Custom MicroStrategy Visualizations on the iPad: Part 1

As mentioned in the above post, and covered in detail in the post Getting MicroStrategy Data Into Your Control, the traditional way of deploying Widgets and Visualizations pulls the data in locally from the Report or Document that it’s attached to.  But when we deploy the visualization to the iPad as a standalone application, it doesn’t have MicroStrategy behind it.  That means that we have to modify that code so that the application can pull the data itself.

There are two key pieces of code that make it possible:

initializeFromReport(TASKPROC_URL, SESSION_STATE, REPORTGUID)

This will pull the data from a report.  It’s pretty straightforward to use, the SERVER_URL is the path to the TaskProc and it will handle the data requests for us.  The REPORTGUID is the Object ID of the report that we want to run.  The tricky part is the SESSION_STATE.  This is your Session information that represents your login instance to MicroStrategy.  Fortunately, this is handled for us by the MicroStrategy framework as well with LoginTask object.  This will handle the login and retrieve the Session State for us, without having to worry about any of the behind the scenes guts.

Sound easy?  It was!  Full code here:

private function onComplete():void {
var loginTask:LoginTask = new LoginTask("http://YOURSERVER/microstrategy/asp/taskAdmin.aspx");
loginTask.user = "USER";
loginTask.password = "PASSWORD";
loginTask.server = "SERVER";
loginTask.project = "PROJECT";
loginTask.authMode = 1; //Standard Authentication
loginTask.addEventListener(TaskEvent.SUCCESS, handleLoginSuccess);
loginTask.addEventListener(TaskEvent.FAILURE, handleLoginFailure);
loginTask.execute();
}

private function handleLoginSuccess(evt:TaskEvent):void {
(Controller.getInstance(appNameSpace)).initializeFromReport("http://YOURSERVER/microstrategy/asp/taskAdmin.aspx", LoginTask(evt.getTask()).getSessionState(), REPORTGUID);
(Controller.getInstance(appNameSpace)).createModel("model1");
(Controller.getInstance(appNameSpace)).addEventListener(ControllerEvent.VIEWER_MODEL_REQUESTS_COMPLETE, buildControl);
}

private function handleLoginFailure(evt:TaskEvent):void {
Alert.show(evt.getMessage());
}

The first thing the application should do is run the onComplete() function to get things setup.  This is where we setup the LoginTask and configure all of the login properties.  We also add two EventListeners so that we can grab the data once it’s successfully logged in, or see the error if it fails.  Once the login is complete, we can call InitializeFromReport() and pass in the parameters, and use getSessionState() from the LoginTask to get our Session information.  After that, the next two lines should look familiar because they simply create our Derived Model and launch our function to create the rest of our control.  The rest of the application code is identical to anything else you’ve built or used before, including the code to pull the data out of the Derived Model.

Two More Tricks
Honestly, these silly steps are what took me a month to finally untangle.

The first is that while I’ve only ever needed VisFramework.swc in my project library for the MicroStrategy Framework, you would quickly notice that it’s not enough.  The LoginTask lives in com.microstrategy.flex.controller.tasks.LoginTask, and you’ll notice that it doesn’t exist in VisFramework.  The trick is that you have to also add ReportServicesFlexAPI.swc to your project.  This is found in the same SDK location, and more information can be found in the post Setting up a Flex Environment for Building MicroStrategy Widgets.

The second issue may be harder for you to resolve or even a deal breaker.  The issue is that most environments are internal distributions, and the iPad is almost certainly not on your internal network.  While the iPad does contain VPN capabilities, it may not be allowed or supported on your network.  In my case, I was able to VPN from my iPad to my company network in order to access my MicroStrategy installation.  The bigger problem for me though was handling the Windows Authentication.  Since the TaskProc call is made over an HTTP connection, the web browser would generally pop up a login.  This application doesn’t do that, and I haven’t yet found a way for it to support NT Authentication with IIS (though honestly, I haven’t really tried either).  In order for my test case to work, I had to change the IIS Authentication to enabled Anonymous and disabled Windows Authentication.  This allows connections without first authenticating, and thus allows the iPad connection to connect.

Supporting Windows Authentication is definitely the next problem to solve, though it’s honestly a minor one.  Worst case, you could setup a separate Web installation (free if you are on a Named User License model) that only contains the TaskProc files.  This would allow you to use a separate Web Server accessible via the Internet so that the iPad could connect without VPN or Authentication.  However you solve that particular issue, it’s really the only sticking point between unleashing your existing MicroStrategy Flash Visualizations as iPad/Playbook/Android native apps.

You may also like...