Share via


DiscoveryDocumentReference.Document 属性

定义

将所引用的发现文档的内容作为 DiscoveryDocument 对象获取。

public:
 property System::Web::Services::Discovery::DiscoveryDocument ^ Document { System::Web::Services::Discovery::DiscoveryDocument ^ get(); };
public System.Web.Services.Discovery.DiscoveryDocument Document { get; }
member this.Document : System.Web.Services.Discovery.DiscoveryDocument
Public ReadOnly Property Document As DiscoveryDocument

属性值

DiscoveryDocument,它表示所引用的发现文档的内容。

例外

ClientProtocol 属性为 null

- 或 -

在使用 ClientProtocol 下载或解析 XSD 架构的过程中发生错误。

示例

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);
   }
}
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

注解

如果尚未下载发现文档并将其添加到 DocumentsClientProtocol属性,则会尝试下载并解析文档。

适用于