This article describes how to render a list of data sources and dataset's from with a Report Definition (.RDL) file, while using the SQL Server Reporting Services Web Services. You will find a dowload of the code at the end of the article.

You will notice a new folder named Web References with RS2005 reference located within the folder.

You have completed referencing the Reporting Services WSDL

Add Web Form

1) Create a new Web Form and name it "RSDataset.aspx".

Reference Namespaces

1) Open the RDLUpload.aspx.cs and add the following additional namespaces:

using System.Web.Services.Protocols; // protocols used to transmit data across the wire using ASP.NET

using RSIntegrationDemo.RS2005; // your wsdl reference

//used for ListReportDataset

using System.Xml;

using System.Xml.XPath;

using System.IO;

Adding the Data Source Code

The ListReportDataSource method will return all data sources within a report, by using the GetItemDataSources method, within the Reporting Services SOAP API. The custom method ListReportDataSource takes one parameter - ReportPath (string).

///<summary>

/// lists all datasources within a report definition (.rdl)

///</summary>

///<param name="reportName"></param>

privatevoid ListReportDataSource(string reportPath)

{

DataSource[] dataSources = null;

try

{

dataSources = rs.GetItemDataSources(reportPath);

if (dataSources != null)

{

foreach (DataSource ds in dataSources)

{

Response.Write(ds.Name + "<br />");

}

}

}

catch (SoapException e)

{

Response.Write(e.Detail.InnerXml.ToString());

}

}

Adding the Dataset Source Code

The ListReportDataset method will return all dataset items within a report, by using the GetReportDefinition method, within the Reporting Services SOAP API. In addition to the GetReportDefinition, we use the following objects to help with reading the stream:

byte[] - array of bytes

XmlDocument - Represents an XML document

MemoryStream - Creates a stream whose backing store is memory. In this case we use for initializing a new non-resizable instance of the MemoryStream class based on the specified byte array.

The file seems to be fine. We were able to download and extract on several different computers.

Other:

After extracting the .zip, you may need to convert the project to your version of Visual Studio. For example, the downloadable solution was built using VS 2008. If you're using VS 2010, you'll need to perform the conversation, so the project files open without error.

3) Within the RDDataset.cs file, under Page_Load(...), make sure you use existing report paths from your environment. For example, "/Corporate Reports/Company Sales 2008" is a specific path we used for the demo, we can assume you wouldn't have the same path to folders/reports.