DiscoveryClientProtocol.ResolveAll 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
解析 References 屬性中對探索文件、XML 結構描述定義 (XSD) 結構描述和服務描述的所有參考,以及在參考的探索文件中找到的參考。
public:
void ResolveAll();
public void ResolveAll ();
member this.ResolveAll : unit -> unit
Public Sub ResolveAll ()
範例
下列程式碼範例是 Web Form,會填 DataGrid 入 屬性中 Documents 檔的詳細資料,以及 XML Web 服務探索期間在每個檔中找到的參考。 方法 PopulateGrid
會 DataGrid 以調用的結果 DiscoverAny 填滿 ,後面接著呼叫 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 。 和 ResolveOneLevel 都會 ResolveAll 下載並驗證 屬性中的 References XSD 架構和服務描述。 不過,這兩種方法處理探索檔的方式不同。 ResolveOneLevel 會解析 屬性內探索檔中的所有 References 參考;如果探索檔包含其他探索檔的參考, ResolveOneLevel 則只會解析這些探索檔。 在巢狀一層深度的探索檔中找到的探索檔不會由 ResolveOneLevel 解析,而 ResolveAll 會全部解析。 ResolveAll 會繼續解析巢狀探索檔中的參考,直到沒有其他參考為止。
在驗證 ResolveAll 程式期間發生的錯誤不會在發生時擲回,而是收集並新增至 Errors 屬性。