在 Web 应用程序中使用 SOAP API

可以通过 Reporting Services SOAP API 访问报表服务器的完整功能。 由于它是 Web 服务,因此可以轻松访问 SOAP API,以便为自定义业务应用程序提供企业报告功能。 从 Web 应用程序访问报表服务器 Web 服务的方式与从 Microsoft Windows 应用程序访问 SOAP API 的方式大致相同。 使用 Microsoft .NET Framework,可以生成一个代理类,该类公开报表服务器 Web 服务的属性和方法,并使你能够使用熟悉的基础结构和工具在 Reporting Services 技术上生成业务应用程序。

Reporting Services 报表管理功能与从 Windows 应用程序一样轻松地从 Web 应用程序访问。 在 Web 应用程序中,可以添加和删除报表服务器数据库中的项、设置项安全性、修改报表服务器数据库项、管理计划和传递等。

启用模拟

配置 Web 应用程序的第一步是从 Web 服务客户端启用模拟。 通过模拟,ASP.NET 应用程序可以使用代表其作的客户端的标识执行。 ASP.NET 依赖于Microsoft Internet Information Services(IIS)对用户进行身份验证,并将经过身份验证的令牌传递给 ASP.NET 应用程序,或者(如果无法对用户进行身份验证),请传递未经身份验证的令牌。 无论哪种情况,ASP.NET 应用程序都模拟启用模拟时接收的令牌。 可以通过修改客户端应用程序的 Web.config 文件,在客户端上启用模拟,如下所示:

<!-- Web.config file. -->  
<identity impersonate="true"/>  

注释

默认情况下禁用模拟。

有关 ASP.NET 模拟的详细信息,请参阅 Microsoft .NET Framework SDK 文档。

使用 SOAP API 管理报表服务器

还可以使用 Web 应用程序来管理报表服务器及其内容。 Reporting Services 随附的报表管理器是使用 ASP.NET 和 Reporting Services SOAP API 完全生成的 Web 应用程序的示例。 可以将报表管理器的报表管理功能添加到自定义 Web 应用程序。 例如,你可能想要返回报表服务器数据库中可用报表的列表,并将其显示在 ASP.NET Listbox 控件中供用户选择。 以下代码连接到报表服务器数据库,并返回报表服务器数据库中的项列表。 然后,将可用报表添加到 Listbox 控件,该控件显示每个报表的路径。

Private Sub Page_Load(sender As Object, e As System.EventArgs)  
   ' Create a Web service proxy object and set credentials  
   Dim rs As New ReportingService2005()  
   rs.Credentials = System.Net.CredentialCache.DefaultCredentials  
  
   ' Return a list of catalog items in the report server database  
   Dim items As CatalogItem() = rs.ListChildren("/", True)  
  
   ' For each report, display the path of the report in a Listbox  
   Dim ci As CatalogItem  
   For Each ci In  items  
      If ci.Type = ItemTypeEnum.Report Then  
         catalogListBox.Items.Add(ci.Path)  
      End If  
   Next ci  
End Sub ' Page_Load   
private void Page_Load(object sender, System.EventArgs e)  
{  
   // Create a Web service proxy object and set credentials  
   ReportingService2005 rs = new ReportingService2005();  
   rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  
  
   // Return a list of catalog items in the report server database  
   CatalogItem[] items = rs.ListChildren("/", true);  
  
   // For each report, display the path of the report in a Listbox  
   foreach(CatalogItem ci in items)  
   {  
      if (ci.Type == ItemTypeEnum.Report)  
         catalogListBox.Items.Add(ci.Path);  
   }  
}  

另请参阅

使用 Web 服务和 .NET Framework 生成应用程序
将 Reporting Services 集成到应用程序中
报表管理器(SSRS 本机模式)
在 Windows 应用程序中使用 SOAP API