DiscoveryClientProtocol.DiscoverAny メソッド
指定した URL を探索して、この URL が探索ドキュメントであるか、サービスの説明であるか、または XML スキーマ定義 (XSD) スキーマであるかを判断します。
Public Function DiscoverAny( _
ByVal url As String _) As DiscoveryDocument
[C#]
public DiscoveryDocument DiscoverAny(stringurl);
[C++]
public: DiscoveryDocument* DiscoverAny(String* url);
[JScript]
public function DiscoverAny(
url : String) : DiscoveryDocument;
パラメータ
- url
XML Web サービス探索を開始する URL。
戻り値
指定された URL にある、XML Web サービス探索の結果を格納している DiscoveryDocument 。 url パラメータがサービスの説明または XSD スキーマを参照している場合は、メモリ内に DiscoveryDocument が作成されます。
例外
例外の種類 | 条件 |
---|---|
WebException | 指定した URL へのアクセスにより、 OK 以外の HTTP ステータス コードが返されました。 |
InvalidOperationException | url パラメータは有効な URL ですが、有効な探索ドキュメント、サービスの説明、XSD スキーマのいずれも指していません。 |
解説
DiscoverAny メソッドでは、指定された URL が探索ドキュメントであるか、サービスの説明であるか、または XSD スキーマかどうかを調べます。URL が探索ドキュメントだけを参照していることが判明している場合は、 Discover メソッドを呼び出してもかまいません。
指定された URL が有効な探索ドキュメント、XSD スキーマまたはサービスの説明を指している場合は、その指定された URL が指している探索ドキュメントが Documents コレクションおよび References コレクションに追加されます。指定された URL が XSD スキーマまたはサービスの説明を参照している場合は、メモリ内に DiscoveryDocument が作成され Documents コレクションおよび References コレクションに追加されます。さらに、探索ドキュメント内の参照が References コレクションに追加されますが、その参照が有効な探索ドキュメントを指しているかどうかは検証されません。参照が有効な探索ドキュメントを指しているかどうかを検証するには、 ResolveAll メソッドまたは ResolveOneLevel メソッドを呼び出します。
使用例
[Visual Basic, C#] Documents プロパティのドキュメントの詳細と共に、XML Web サービスの探索中に各ドキュメントで見つかった参照を DataGrid に読み込む Web フォームのコード例を次に示します。 PopulateGrid
メソッドは、 DiscoverAny 呼び出しおよびそれに続く ResolveAll 呼び出しの結果を DataGrid に設定します。
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 the DataGrid 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
[C#]
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>";
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
DiscoveryClientProtocol クラス | DiscoveryClientProtocol メンバ | System.Web.Services.Discovery 名前空間