PerformancePoint Monitoring Web Service – Part 1

Update: Part 2

Update: Part 3

Both the Planning and Monitoring components of PPS provide their functionality via web services.  Martyn and I spent quite a while picking the planning web service apart for our web part.  It was less than straight-forward as it uses the same method to carry out different functions with different objects.  The Monitoring Web Service by comparison is much easier to decipher.  You view the methods by entering the following in your web browser:

http://:40000/WebService/PmService.asmx

image

Most of the things you can do in Dashboard Designer and SharePoint are included in the list which means the possibilities of what you can do programmatically are huge!  On top of this there’s also the Monitoring SDK which allows even further extensibility such as custom reports/data sources.

Over the next few weeks/months I’ll be taking a look at the Monitoring web service in more detail and showing examples of what you can do with it.  This week it’s 101 – connect to the web service and list objects.  And no comments on the quality of my code – it’s been a while!

The first thing we need to is set up a visual studio project.  This could be a web project, Windows form, web part etc.  In this example we’ll be creating a simple web page so are using a asp.net web site project.  Next add a web reference to the Monitoring Web Service by right-clicking on your project in the solution explorer pane:

image

Enter the address of the web service as per above and give it a suitable reference name (in the examples below it’s PPSM).  To keep things simple I’m going to just add the code to the page load event of the default page.  First we have to initialise the web service and pass it our credentials:

protected void Page_Load(object sender, EventArgs e)
{
    //initialise the web service
    PPSM.PmService mon = new PPSM.PmService();
    //you could make the url of the web service configurable
    //mon.Url = 

    //next we have to pass the logged on user credentials to make
    //sure that we have permissions to make the web servoce calls
    mon.Credentials = System.Net.CredentialCache.DefaultCredentials;

 

From here we can now call the web service methods as required.  First of all lets list the dashboards on our server and loop through them listing the name using the GetDashboards method.  Note that we have to use a BpmPropertyText object to get to the dashboard title.

//now we simply use web service calls to get the objects
PPSM.Dashboard[] dash = mon.GetDashboards();

//loop through the dashboard array and print the title
for (int a = 1; a < dash.Length; a++)
{
    //in this case we have to pass the title back in a BpmPropertyText object
    PPSM.BpmPropertyText dashname =  (PPSM.BpmPropertyText)dash[a].Properties[0];
    Response.Write(dashname.Text);

}

Lets do the same now with Scorecards using the (yep you guessed it) GetScorecards method:

//declare an array of scorecard objects and initialise using the
//get scorecards method
PPSM.Scorecard[] scd = mon.GetScorecards();

//loop through the scorecard array and print the title
for (int j = 1; j < scd.Length; j++)
{
    //again we have to pass the title back in a BpmPropertyText object
    PPSM.BpmPropertyText scdname =  (PPSM.BpmPropertyText)scd[j].Properties[0];
    Response.Write(scdname.Text);
}

Next we can do some specific things with each of the scorecards in the array.  In this case get all the KPI’s associated with each scorecard using the GetKpisFromScorecard. This take an argument of the scorecard guid which we can get from the array elements in our previous call

//next we're going to get the kpi's for the current scorecard 
PPSM.Kpi[] kpi = mon.GetKpisFromScorecard(scd[j].Guid);

Response.Write("Kpis in " + scdname.Text + "");
Response.Write("
");

for (int i = 1; i < kpi.Length; i++)
{
    PPSM.BpmPropertyText kpiname = (PPSM.BpmPropertyText)kpi[i].Properties[0];
    Response.Write(kpiname.Text);
     
}

No need to clean up any connections – one of the perks of the web service (everything is returned as xml objects).

Pretty straightforward stuff really.  Next time we’ll look a bit deeper!  I’ve attached the sample project below.  It has a web reference to a localhost monitoring service so you’ll need to update it if you’re running the code against a remote server.  There’s no solution file as it’s a web site project so you’ll need to use the open web site option in VS.

PPSMWebService.zip (24.93 kb)