设置 GetProperties 方法的项命名空间
可以根据两个不同的项标识符在 Reporting Services 中使用 ItemNamespaceHeader SOAP 标头:项的完整路径或项的 ID。
当您调用 GetProperties 方法时,通常将要检索其属性的项的完整路径作为参数传递。 使用 ItemNamespaceHeader,您可以为方法调用设置 SOAP 标头,以便通过将项的 ID 作为标识符传递来使用 GetProperties。
以下代码示例根据项的 ID 检索项属性的值。
注意
默认情况下,如果您将完整路径名称作为项标识符传递到 ItemNamespaceHeader 方法,则不需要为 GetProperties 设置值。
Imports System
Imports System.Collections
Class Sample
Sub Main()
Dim rs As New ReportingService2010()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = "https://<Server Name>/reportserver/ReportService2010.asmx"
Dim items() As CatalogItem
Try
' Need the ID property of items. Normally, you would already have
' this stored somewhere.
items = rs.ListChildren("/AdventureWorks Sample Reports", False)
' Set the item namespace header to be GUID-based
rs.ItemNamespaceHeaderValue = New ItemNamespaceHeader()
rs.ItemNamespaceHeaderValue.ItemNamespace = ItemNamespaceEnum.GUIDBased
' Call GetProperties with item ID.
If Not (items Is Nothing) Then
Dim item As CatalogItem
For Each item In items
Dim properties As [Property]() = rs.GetProperties(item.ID, Nothing)
Dim property As [Property]
For Each property In properties
Console.WriteLine(([property].Name + ": " + [property].Value))
Next property
Console.WriteLine()
Next item
End If
Catch e As Exception
Console.WriteLine((e.Message + ": " + e.StackTrace))
End Try
End Sub 'Main
End Class 'Sample
using System;
using System.Collections;
class Sample
{
static void Main()
{
ReportingService2010 rs = new ReportingService2010();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "https://<Server Name>/reportserver/ReportService2010.asmx";
CatalogItem[] items;
try
{
// Need the ID property of items. Normally, you would already have
// this stored somewhere.
items = rs.ListChildren("/AdventureWorks Sample Reports", false);
// Set the item namespace header to be GUID-based
rs.ItemNamespaceHeaderValue = new ItemNamespaceHeader();
rs.ItemNamespaceHeaderValue.ItemNamespace = ItemNamespaceEnum.GUIDBased;
// Call GetProperties with item ID.
if (items != null)
{
foreach( CatalogItem item in items)
{
Property[] properties = rs.GetProperties(item.ID, null);
foreach (Property property in properties)
{
Console.WriteLine(property.Name + ": " + property.Value);
}
Console.WriteLine();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}