DiscoveryClientProtocol.ResolveOneLevel 方法

定義

解析 References 中對探索文件、XML 結構描述定義 (XSD) 結構描述和服務描述的所有參考,以及在那些探索文件中找到的參考。

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

範例

下列程式碼範例是 Web Form, DataGrid 會在 XML Web 服務探索期間填入 屬性中 Documents 檔的詳細資料,以及每個檔中找到的參考。 方法 PopulateGridDataGrid 以調用的結果 DiscoverAny 填入 ,後面接著呼叫 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 屬性。

適用於