MicroStrategy ONE
Executing a Report and Retrieving the Results
The code sample shown below illustrates how to execute a report and retrieve the results.
Code sample
// obtain the WebObjectsFactory object by calling the getInstance static method
WebObjectsFactory woFact = WebObjectsFactory.getInstance();
// instantiate the WebIServerSession object and use it to obtain a session for the given project
WebIServerSession webSS = woFact.getIServerSession();
webSS.setServerName("localhost");
webSS.setLogin("administrator");
webSS.setProjectName("MicroStrategy Tutorial");
webSS.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
// Create the WebReportSource, object which is the entry point to the report execution and manipulation functionality
WebReportSource reptSrc = woFact.getReportSource();
// Specify a particular report ID and use it to create a new WebReportInstance object
String reportID = "A20C8AC711D60AE310008BB3D1CEE6A4"; // report dssID
WebReportInstance rptInst = reptSrc.getNewInstance(reportID);
// Set the mode to be synchronous
rptInst.setAsync(false);
// Cause the API to poll Intelligence Server to obtain the results and return them to the user as a string
String xmlResult = rptInst.getResultsAsXML();
This code is used by the code in the topic, Pivoting an Attribute of an Executed Report and Retrieving the Results.