本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

DiscoveryDocumentReference.ResolveAll 方法 ()

 

驗證探索文件中的所有參考文件有效。

命名空間:   System.Web.Services.Discovery
組件:  System.Web.Services (於 System.Web.Services.dll)

public void ResolveAll()

Exception Condition
InvalidOperationException

ClientProtocol 屬性為 null

-或-

無法下載及驗證成功探索文件。

除非您特別需要解決的個別參考 DiscoveryDocumentReference 物件時,您應該會叫用 ResolveAllResolveOneLevel 方法 DiscoveryClientProtocol

這個方法可以解決探索文件、 XSD 結構描述,以及服務描述中的所有參考 References 屬性 ClientProtocol 和參考探索文件中找到的所有參照。

using System;
using System.Web.Services.Discovery;
using System.Collections;
using System.Security.Permissions;

class DiscoveryDocumentReference_Document_ResolveAll
{
   static void Main()
   {

      Run();
   }

   [PermissionSetAttribute(SecurityAction.Demand, Name="FullTrust")]
   static void Run()
   {
      try
      {
         string myUrl = "http://localhost/Sample_cs.vsdisco";
         DiscoveryClientProtocol myProtocol = new DiscoveryClientProtocol();
         // Get the discovery document myDiscoveryDocument.
         DiscoveryDocument myDiscoveryDocument = myProtocol.Discover(myUrl);
         // Get the references of myDiscoveryDocument.
         IEnumerator myEnumerator = myDiscoveryDocument.References.GetEnumerator();
         while(myEnumerator.MoveNext())
         {
            DiscoveryDocumentReference myNewReference = 
                           (DiscoveryDocumentReference)myEnumerator.Current;
            // Set the ClientProtocol of myNewReference.
            DiscoveryClientProtocol myNewProtocol = myNewReference.ClientProtocol;
            // Verify for all the valid references.
            myNewReference.ResolveAll();

            // Get the document of myNewReference.
            DiscoveryDocument myNewDiscoveryDocument = 
                                                 myNewReference.Document;

            IEnumerator myNewEnumerator = 
                           myNewDiscoveryDocument.References.GetEnumerator();
            Console.WriteLine("The valid discovery document is : \n");
            while(myNewEnumerator.MoveNext())
            {
               // Display the references of myNewDiscoveryDocument on the console.
               Console.WriteLine(((DiscoveryDocumentReference)myNewEnumerator.Current).Ref);
            }
         }
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception :{0}", e.Message);
      }
   }
}

.NET Framework
自 1.1 起供應
回到頁首
顯示: