Thursday, January 20, 2011

Playing around with CMS

CMS or Cognos Mashup Services is a Cognos component available starting from Cognos 8.4.1 as part of your Cognos SDK software. CMS exposes Cognos objects like reports as web services and thus allows you to integrate them into other environments. There are multiple formats and interfaces through which these web services can be exposed namely SOAP and REST but I am not going to bore you with jargon here. I am not going to try and explain the differences between using SDK and CMS in this article either. This article is just to give you a glimpse of what one can do with CMS and to demonstrate one of the many CMS features.

I have been playing around with the REST interface of CMS and am going to begin by showing you what I have been able to do using this.Technical information on CMS, REST and SOAP will follow later :-)

There are a number of ways you can use the REST interface. I have been playing around with just one of those ways that I will be demonstrating in this article.

To retrieve report data using CMS you create a URL as below:

http://localhost:81/cognos84/cgi-bin/cognos.cgi/rds/reportData/path/Public%20Folders/Reports/Sample%20Report%201?fmt=HTML



The URL consists of the Cognos application detail, and the path of the report along with the fmt in which you wish to see the data. The formats supported are XML, HTML or JSON.

To access one of the objects in the report you need to use the name of the object in the report.

Example: We have a report that includes a list and chart object.



To access the chart object alone:

http://localhost:81/cognos84/cgi-bin/cognos.cgi/rds/reportData/path/Public%20Folders/Reports/Sample%20Report%203?selection=CombinationChart1&fmt=HTML

where CombinationChart1 is the name of the Chart object.



Though you can access report content through URLs using CMS as well, this technique differs from parametrized URL method in that you cannot append prompt values to the URL and also, the above URL will work in an environment where anonymous access is allowed or if you try this in a browser in which you are already logged into Cognos thus re-using the existing Cognos session.

To provide authentication details and prompt values the CMS REST interface needs to be used through a programming language where in you will invoke the CMS authentication web services.The URLs need to be used through the programming application. I will be providing examples on the same in upcoming articles.

Using XPaths in your requests:

XPath is a language to navigate through an XML document. More on XPaths in another article only if folks are interested.

When you use XPaths in your request the output is always returned in XML format. XPaths allow you to get data from very specific sections in your report like say the group header or the first column in your report etc.

Example: To retrieve the data from a single column in your report say you want to view the PRODUCTTYPE_ID column data displayed in Img 1 of the post:

http://localhost:81/cognos84/cgi-bin/cognos.cgi/rds/reportData/report/i1AD2E77046F74BFD8C3B916CF4FD66C2?xpath=/document/page/body/item/lst/group/row/cell[1]/item/txt/val




Now you can use this XML output retrieved in your programming application and display/integrate the data as required in your external application.
 

2 comments:

PaulM said...

I'd be interested in reading more on XPaths.

Zephyr said...

Sure..Will post on XPaths sometime this week.