DiscoveryClientProtocol.ResolveOneLevel 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
解析 References 中對探索文件、XML 結構描述定義 (XSD) 結構描述和服務描述的所有參考,以及在那些探索文件中找到的參考。
public:
void ResolveOneLevel();
public void ResolveOneLevel ();
member this.ResolveOneLevel : unit -> unit
Public Sub ResolveOneLevel ()
範例
下列程式碼範例是 Web Form, DataGrid 會在 XML Web 服務探索期間填入 屬性中 Documents 檔的詳細資料,以及每個檔中找到的參考。 方法 PopulateGrid
會 DataGrid 以調用的結果 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 屬性。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應