Udostępnij przez


Ustawianie metoda GetProperties obszar nazw elementu

Można użyć ItemNamespaceHeader Nagłówek protokołu SOAP w Reporting Services Aby pobrać właściwości elementu, oparty na dwóch identyfikatorów inny element: Pełna ścieżka element lub identyfikator element.

Po dokonaniu wywołanie GetProperties(String, array<Property[]) metoda, które zwykle przekazać jako argument pełną ścieżka do element, dla której chcesz pobrać właściwości. Za pomocą ItemNamespaceHeader, zestaw nagłówek protokołu SOAP na Twoje wywołanie metoda umożliwić użytkownikowi korzystanie z GetProperties(String, array<Property[]) przekazując identyfikator element jako identyfikator.

Poniższy przykładowy kod pobiera wartości dla właściwości element, na podstawie IDENTYFIKATORA element.

Uwaga

Domyślnie nie ma potrzeby ustawiania wartości dla ItemNamespaceHeader przekazywane do GetProperties(String, array<Property[]) Metoda pełną nazwę ścieżka jako identyfikator element.

Imports System
Imports System.Collections
Imports myNamespace.MyReferenceName


Class Sample
   Sub Main()
      Dim rs As New ReportingService2005()
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials
      rs.Url = "http://<Server Name>/reportserver/ReportService2005.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;
using myNamespace.MyReferenceName;


class Sample
{
   static void Main()
   {
   ReportingService2005 rs = new ReportingService2005();
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
      rs.Url = "http://<Server Name>/reportserver/ReportService2005.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);
      }
   }
}