Blogs

Ted Ueda

Polestar in the cloud Web Services API - Sample Codes
Ted Ueda SAP Employee Active Contributor Silver: 500-1,499 points
Business Card
Company: SAP
Posted on Mar. 09, 2009 10:36 AM in Enterprise Data Warehousing/Business Warehouse, Business Intelligence (BusinessObjects), Interoperability .NET, Java Programming, Python, Scripting Languages, Service-Oriented Architecture

Subscribe.Subscribe
Print. Print
Permalink Permalink
Share

I work for SAP Business Objects in Technical Customer Assurance.  My speciality is the Software Development Kits (SDKs) that we provide with our Business Intelligence products - BusinessObjects Enterprise, Web Intelligence, Desktop Intelligence, Crystal Reports and Crystal Xcelsius. 

In my blog, I discuss subjects that I personally find interesting - little known or not-well-documented corners of the SDK, new functionality or new SDKs, or interesting issues that I've come across in a SAP Incident or SAP Developer Network forums. 

You're more than welcome to suggest any topic (SAP Business Objects SDK related, of course...) that you'd like me to discuss - I have a dozen or so items on my blog to-do list, but I'm always on the hunt for anything interesting with our SDKs.   

*** Update: revised Flex sample to use the new suppress_response_codes feature (thanks, Bo!) to work with Internet Explorer! ***

If you're interested in Polestar in the cloud and the recently announced Polestar in the cloud API $20K IDEAtion Challenge, then this blog entry may be of interest to you.   I'm going to present here a few sample codes for that API, so you'll quickly get up to speed and have a head start on the competition!

Each of the sample codes follow the same workflow: retrieve data, upload the dataset to OnDemand, then view it in Polestar in the cloud.  What differs is the programming language used and the data source.  The four samples are:

 

  1. Python script with inline dataSet.
  2. C# with data retrieved from Query as a Web Service
  3. Xcelsius SDK - Adobe Flex component.
  4. Java with RSS Feed data.
Polestar in the cloud API

Ty Miller, a Techical Director here, sent me email about a month ago asking whether I was interested in checking out a cool new Web Services API for the BusinessObjects Labs project called Polestar in the cloud. I figured whatever Ty's involved in is high on the hot-and-interesting scale - he's sent a few pretty interesting Customer Support cases my way in the past - but at the time I was busy helping customers and working with Crystal Reports for Eclipse 2.0 and Universe Data Access Driver Development Kit SDK, so I had to flag his email for later action.

Rob Horne, who's also into pretty interesting stuff, recently blogged about Polestar in the cloud.  Reading his blog certainly encouraged me to check it out  (although I have to say I'm far from a Steve Nash fan), and what I found was pretty impressive. 

Polestar makes the relationship between you and your data highly personal - I've gotten tremendous insight, and seen relationships I've not thought of, merely by uploading data and working with it in Polestar.  Having Polestar as part of the "Cloud" computing on Whohar - the http://create.ondemand.com/ portal - makes it that much more compelling.  Now you can upload and store your data on Whohar, and analyze it using different dashboards as well as Polestar. 

Programmatic dataset management is accomplished via the Whohar RESTful Web Services API - you can upload, download, update and delete datasets via simple HTTP calls.  You can then invoke a URL to view a dataset in Polestar.

The beauty of the API is in its simplicity - you're able to code against it using most programming languages out there, and have a very elegant means to integrate your app with Polestar in the cloud.

Rob kindly sent me a preview of the Whohar API docs - it's now available publicly here - and I've been playing with the API since.    I've cleaned up some of my sample codes and present it here for your enjoyment.  I do hope it helps you in quickly working out the API workflow required to integrate your stuff with Polestar in the cloud.

Python Script with Inline DataSet

Here's a short Python script that I used to get a 'feel' for the API -

Python script uploading data to Polestar in the cloud

that shows the basics of uploading a dataSet and viewing it in Polestar: the required XML dataset format, setting up the HTTP Basic Authentication, retrieving the dataSet ID and session ID, and redirecting to Polestar in the cloud.

Edit the top of the file to insert your create.ondemand.com logon credentials, and modify the bottom to use either the webbrowser lib or explicit launching of a web browser, and run it using the Python interpreter.

You'll note how simple the API is - the advantage of using a RESTful Web Services design.

C# With Data Retrieved from Query as a Web Service

A bit more useful example, using C# - I wrote it on Visual Studio 2008 - that consumes data from Query as a Web Service (QaaWS), upload them to Whohar and view in Polestar in the cloud.  Here's a screenshot of what you get, showing both the QaaWS client with the query, and the Polestar view of the data:

 

image

 

The query is based on the eFashion sample Universe, and Polestar is displaying the breakdown of sales revenue, quanitity of merchandise sold, and margin for stores by State.  Texas is looking pretty good (more on Texas later)...

Here's the code:

C# 2008 to upload QaaWS-generated data to Polestar OnDemand

You'll note that much of the code is taken up by the QaaWS SOAP Web Service call - dynamically generating stub code from the WSDL, auto-compiling and loading the assembly, and using Reflection to invoke the service - and not by the OnDemand API. 

It may be an unfair comparison, but this does suggest the simplicitly of a RESTful Web Service in comparison to SOAP. 

Compile the code using Visual Studio 2008, and run it in the command-line:

QaaWS2Polestar.exe <QaaWS WSDL URL> <QaaWS user> <QaaWS password> <Whohar user> <Whohar password>

and it'll launch Internet Explorer with Polestar OnDemand view of your QaaWS data.

A couple of comments about the sample code:

  1. It generates the QaaWS stubs from the WSDL using .NET Service Reference rather than Web Reference.  A Service-Reference-generated-code makes for easier Reflection into the stub classes, since you can infer use from the generated property names.
  2. It currently doesn't set any QaaWS prompts - you can add to the Reflection routine near the end of the code to introspect any prompts.
Xcelsius SDK - Adobe Flex Component

I created this sample using Adobe Flex Builder 3 and the Xcelsius SDK.  Implementation uses MXML that subclasses a mx:Button component that, when clicked, reads a bound 2D Array, constructs the Whohar dataSet XML, uploads the data and displays it in Polestar in the cloud.

You can use it within an Adobe Flash application or embedded in Xcelsius.  Here's a screenshot of it embedded within Xcelsius, showing both the Polestar and Xcelsius views of the data:

 

image

 

When you click on the "To Polestar OnDemand" button you see on the Xcelsius view, the Polestar OnDemand view is displayed.The data is just some test data I entered into Excel in the Xcelsius designer - in actual practise, you'd be using 'real' Excel data, or a Web Service data source. 

Here's the MXML code:

PolestarOnDemand.xml - uploads bound Array to Polestar in the cloud

and the MXML for the Logon dialog box it uses to collect the OnDemand logon credentials:

PolestarOnDemandLogon.xml - Logon dialog box for PolestarOnDemand.xml

Note that the data the component uploads is bound to an 2D array.   Here's a very simple Xcelsius Property Sheet MXML that will allow you to do the binding to Excel cell ranges from within Xcelsius:

PolestarOnDemandPropertySheet.mxml - Xcelsius Property Sheet for PolestarOnDemand.xml

You can also use the component outside of Xcelsius and within a Flex application. Here's a short sample of how you'd invoke PolestarOnDemand.mxml from a mx:Application:

PolestarOnDemandApp.mxml - embedding PolestarOnDemand.mxml component

 

Some comments:

  1. The code passes the parameter suppress_response_codes in the Whohar URL to have responses always return HTTP 200 (other than HTTP 5xx errors).  This feature was added specifically for Flex running in Internet Explorer.  The normal RESTful HTTP 201 (Created) return on new dataset creation throws an exception in Internet Explorer, preventing Flex from reading the returned new resource location.
  2. Xcelsius SDK currently supports Flex 2 only - so in Flex Builder 3, ensure you set the compiler for your project to use version 2 rather than 3.
  3. Flex 2 does not contain a library class for Base64 encoding - I used one of the many open source Base64 implementations for ActionScript available on the web.
  4. Xcelsius supports MXML components via the Xcelsius SDK only starting with FixPack 1.1 (previously, you had to code using ActionScript).  I tested this component using Service Pack 1 + FixPack 1.2.
  5. I didn't Style the component for Xcelsius - if you want to specify fonts and colors for the component in Xcelsius, you'd need to specify styling in the code.  I recommend looking at the ComboBox sample for an example on how to property style a Xcelsius SDK component.
Java With RSS Feed Data

Last example - retrieve data from Yahoo! HotJobs RSS Feed, upload and view in PoleStar OnDemand.  I always wanted to be a spaceman, so I enter 'astronaut' for the HotJobs keyword, and this is the Polestar in the cloud result:

 

image

 

All the astronaut-related jobs are located in Texas!  Most in Houston (as in "Houston, we've got a problem") and a couple in Galveston.  So that means I have to be willing to relocate if I want to fulfill my childhood career aspiration. Oh, well, I think I better stick to more realistic keywords like 'programmer', 'developer', or 'cowboy'.  Maybe I should learn to ride a horse first...

Anyways, here's the Java code:

JobLocationPolestar.java - Polestar in the cloud with data from Yahoo! HotJobs RSS Feed

It's a command-line app where the first argument is the HotJobs keyword and second and third arguments are the OnDeman logon credentials.

It uses the Project ROME RSS Java library to retrieve the feed.

Whohar itself has a RSS feed reader, so you don't necessarily have to use the API to upload RSS entry data into Whohar.  For this task, however, I wanted to post-process the data after retrieving it from Yahoo! and before uploading.  Specifically, I wanted to parse the Job Title fields to derive the job location city and State.

Summary

The Polestar in the cloud and Whohar API has such ease-of-use that you can call it from almost any application. In this blog entry, I illustrated how you'd upload data and display it in Polestar using four different programming languages. 

I'm sure you'll be able to think of much more compelling uses for it than the examples I've given above.  If so, I highly recommend immediately going to the Polestar in the cloud API $20K IDEAtion Challenge site and signing yourself up for a chance to win some recognition for your idea! The cash would be a nice bonus, too...

Hope you find this entry informative, and the sample codes allow you to quickly get up-to-speed with the Polestar in the cloud API.

Ted Ueda  Active Contributor Silver: 500-1,499 points is a Senior Support Engineer with SAP


Comment on this articleAny interesting integration code involving Polestar in the cloud API? Post here!
Comment on this weblog
Showing messages 1 through 10 of 10.

Titles Only Main Topics Oldest First

  • help me in c# coding
    2011-03-03 04:17:21 Ranjith Kumar R Business Card [Reply]

    the document id is not created in the dataset parameter that has to upload in the polestar.. how to include that.. whether that cause the data not to upload in polestar..


    some one help me in this regard

  • Help me on this C# sample Program
    2011-03-03 01:10:15 Ranjith Kumar R Business Card [Reply]

    i had tried the c# sample Program. it works fine by retrieving the data from the QaaWS but when the code upload the dataset to the polestar the dataset is not created in polestar.. please some one help me in this regard..
    i am using .net08 and c# language



    Thanks in advance..

  • Can we upload a file onto whohar? (say a wid or excel file)
    2010-02-23 22:01:01 Raja Panda Business Card [Reply]

    Hi Ted,


    Nice post!! Got to learn a lot from it.


    I have this question though. I tried out your sample code in JobLocationPolestar.java.


    Is there a way I can upload a non-xml based file say for example a .xls file or webi (.wid) file onto whohar and display it on polestar ??
    If yes, can you give me few pointers on how I can do it ?


    Regards
    Raja

  • Polestar OnDemand API no longer works !
    2010-02-17 12:04:15 Anil Jose SAP Employee Business Card [Reply]

    Hi,
    I was able to write flex code and test in Polestar OnDemand early last year. It no longer works for me. I tried the sample code which was given by Ted Ueda - not working. All of these code were working perfectly when i tried in June 2009. Did the Polestar API/input data format change? If yes, is there any documentation on these changes?


    Thanks

  • Really cool
    2009-05-14 00:32:00 Chris Cai SAP Employee Business Card [Reply]

    Thanks Ted, it's really cool demo and a very good starting point for others!
    • Really cool
      2009-05-14 05:26:57 Ted Ueda SAP Employee Business Card [Reply]

      Thanks for the feedback!


      More interesting solutions are provided here:


      https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14262


      Sincerely,


      Ted Ueda

  • Very nice work
    2009-04-02 04:54:16 Mohammad Usama Business Card [Reply]

    Hi
    Thank you very much for your efforts. Its really great that you have initiated the work on this challenge. It also means that you have given four new ideas which perhap are really great.

Showing messages 1 through 10 of 10.