DiscoveryClientProtocol.ResolveOneLevel 方法

定义

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

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

示例

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

 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 references just one level deep/
        client.ResolveOneLevel();
      }
      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 references just one level deep.
     client.ResolveOneLevel()
           
    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

注解

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

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

适用于