DiscoveryDocumentReference.ResolveAll 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
驗證探索文件內的所有參考文件是否有效。
public:
void ResolveAll();
public void ResolveAll ();
member this.ResolveAll : unit -> unit
Public Sub ResolveAll ()
例外狀況
範例
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);
}
}
}
Imports System.Web.Services.Discovery
Imports System.Collections
Imports System.Security.Permissions
Class DiscoveryDocumentReference_Document_ResolveAll
Shared Sub Main()
Run()
End Sub
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Shared Sub Run()
Try
Dim myUrl As String = "http://localhost/Sample_vb.vsdisco"
Dim myProtocol As New DiscoveryClientProtocol()
' Get the discovery document myDiscoveryDocument.
Dim myDiscoveryDocument As DiscoveryDocument = myProtocol.Discover(myUrl)
' Get the references of myDiscoveryDocument.
Dim myEnumerator As IEnumerator = myDiscoveryDocument.References.GetEnumerator()
While myEnumerator.MoveNext()
Dim myNewReference As DiscoveryDocumentReference = _
CType(myEnumerator.Current, DiscoveryDocumentReference)
' Set the ClientProtocol of myNewReference.
Dim myNewProtocol As DiscoveryClientProtocol = myNewReference.ClientProtocol
' Verify for all the valid references.
myNewReference.ResolveAll()
' Get the document of myNewReference.
Dim myNewDiscoveryDocument As DiscoveryDocument = myNewReference.Document
Dim myNewEnumerator As IEnumerator = _
myNewDiscoveryDocument.References.GetEnumerator()
Console.WriteLine("The valid discovery document is : " + ControlChars.NewLine)
While myNewEnumerator.MoveNext()
' Display the references of myNewDiscoveryDocument on the console.
Console.WriteLine(CType(myNewEnumerator.Current, DiscoveryDocumentReference).Ref)
End While
End While
Catch e As Exception
Console.WriteLine("Exception :{0}", e.Message)
End Try
End Sub
End Class
備註
除非您特別需要解析 物件的個別參考 DiscoveryDocumentReference ,否則您應該叫 ResolveAll 用 的 DiscoveryClientProtocol 或 ResolveOneLevel 方法。
這個方法會解析 的 屬性 ClientProtocol 中 References 探索檔、XSD 架構和服務描述的所有參考,以及參考探索檔中找到的任何參考。