您可以透過 Reporting Services SOAP API 存取報表伺服器的完整功能。 因為它是 Web 服務,因此可以輕鬆地存取 SOAP API,為自定義商務應用程式提供企業報告功能。 您可以從 Web 應用程式存取報表伺服器 Web 服務的方式與從 Microsoft Windows 應用程式存取 SOAP API 的方式大致相同。 使用 Microsoft .NET Framework,您可以產生 Proxy 類別來公開報表伺服器 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