共用方式為


設定 GetProperties 方法的項目命名空間

您可以使用 Reporting Services 中的 ItemNamespaceHeader SOAP 標頭,根據兩個不同的項目識別碼來擷取項目屬性:項目的完整路徑或是項目的識別碼。

當您呼叫 GetProperties 方法時,通常會以引數傳遞您要擷取屬性的項目之完整路徑。 您可以透過使用 ItemNamespaceHeader,傳遞項目的識別碼做為識別碼,為方法呼叫設定 SOAP 標頭,以便使用 GetProperties

下列程式碼範例會根據項目的識別碼來擷取項目屬性值。

[!附註]

依預設,如果您以項目識別碼傳遞完整路徑名稱給 GetProperties 方法,則不需要為 ItemNamespaceHeader 設定值。

Imports System
Imports System.Collections


Class Sample
   Sub Main()
      Dim rs As New ReportingService2010()
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials
      rs.Url = "http://<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 = "http://<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);
      }
   }
}

請參閱

概念

技術參考 (SSRS)

其他資源

使用 Reporting Services SOAP 標頭