DiscoveryClientProtocol.ResolveAll 方法

定义

解析所有对 References 属性中的发现文档、XML 架构定义 (XSD) 架构和服务说明的引用以及在引用的发现文档中找到的引用。

public:
 void ResolveAll();
public void ResolveAll ();
member this.ResolveAll : unit -> unit
Public Sub ResolveAll ()

示例

下面的代码示例是一个 Web 窗体,它填充 DataGrid 了属性中 Documents 文档的详细信息,以及 XML Web 服务发现期间在每个文档中找到的引用。 该方法PopulateGrid用调用的结果DiscoverAny填充DataGrid,后跟调用ResolveAll的结果。

 protected void Discover_Click(object Source, EventArgs e)
 {
  // Specify the URL to discover.
  string sourceUrl = DiscoURL.Text;
  // Specify the URL to save discovery results to or read from.
  string outputDirectory = DiscoDir.Text;

      DiscoveryClientProtocol client = new DiscoveryClientProtocol();
  // Use default credentials to access the URL being discovered.
      client.Credentials = CredentialCache.DefaultCredentials;

      try 
      {
        DiscoveryDocument doc;
        
        // Discover the URL for any discoverable documents. 
    doc = client.DiscoverAny(sourceUrl);
   
        // Resolve all possible references from the supplied URL.
        client.ResolveAll();
      }
      catch ( Exception e2) 
      {
        DiscoveryResultsGrid.Columns.Clear();
        Status.Text = e2.Message;
      }
  // If documents were discovered, display the results in a data grid.
      if (client.Documents.Count > 0)
      PopulateGrid(client);

  // Save the discovery results to disk.
      DiscoveryClientResultCollection results = client.WriteAll(outputDirectory, "results.discomap");
      Status.Text = "The following file holds the links to each of the discovery results: <b>" + 
                                  Path.Combine(outputDirectory,"results.discomap") + "</b>";
}
Public Sub Discover_Click(Source As Object, e as EventArgs )
   ' Specify the URL to discover.
   Dim sourceUrl as String = DiscoURL.Text
   ' Specify the URL to save discovery results to or read from.
   Dim outputDirectory As String = DiscoDir.Text

   Dim client as DiscoveryClientProtocol = new DiscoveryClientProtocol()
   ' Use default credentials to access the URL being discovered.
   client.Credentials = CredentialCache.DefaultCredentials
   Try 
     Dim doc As DiscoveryDocument
     ' Discover the URL for any discoverable documents. 
     doc = client.DiscoverAny(sourceUrl)

 ' Resolve all possible references from the supplied URL.
     client.ResolveAll()
           
    Catch e2 As Exception
       DiscoveryResultsGrid.Columns.Clear()
       Status.Text = e2.Message
    End Try

    ' If documents were discovered, display the results in a data grid.
    If (client.Documents.Count > 0) Then
         'populate our Grid with the discovery results
     PopulateGrid(client)
    End If

    ' Save the discovery results to disk.	    
    Dim results As DiscoveryClientResultCollection 
    results = client.WriteAll(outputDirectory, "results.discomap")
    Status.Text = "The following file holds the links to each of the discovery results: <b>" + _ 
                                  Path.Combine(outputDirectory,"results.discomap") + "</b>"
   End Sub

注解

ResolveAll 解析它查找的所有有效引用并将其放置在属性中 Documents 。 同时 ResolveAll 下载并 ResolveOneLevel 验证属性中的 References XSD 架构和服务说明。 但是,这两种方法在处理发现文档的方式上有所不同。 ResolveOneLevel 解析属性中 References 发现文档中的所有引用;如果发现文档包含对其他发现文档的引用, ResolveOneLevel 则仅解析这些发现文档。 在嵌套一个级别深的发现文档中发现的发现文档不是由 ResolveOneLevel该文档解析的;而 ResolveAll 解析它们全部。 ResolveAll 继续解析嵌套发现文档中的引用,直到没有更多引用。

验证过程中 ResolveAll 发生的错误不会在发生时引发,而是收集并添加到 Errors 属性中。

适用于