DiscoveryClientProtocol.Discover(String) メソッド

定義

指定された URL を探索し、探索ドキュメントかどうかを判断します。

public:
 System::Web::Services::Discovery::DiscoveryDocument ^ Discover(System::String ^ url);
public System.Web.Services.Discovery.DiscoveryDocument Discover (string url);
member this.Discover : string -> System.Web.Services.Discovery.DiscoveryDocument
Public Function Discover (url As String) As DiscoveryDocument

パラメーター

url
String

XML Web サービス探索を開始する URL。

戻り値

指定された URL にある、XML Web サービス探索の結果を格納している DiscoveryDocument

例外

指定した URL へのアクセスにより、OK 以外の HTTP ステータス コードが返されました。

url パラメーターは有効な URL ですが、有効な探索ドキュメントを指していません。

次のコード例は、XML Web サービスの検出中に各ドキュメントに含まれる参照と共に、 プロパティ内Documentsのドキュメントに関する詳細を に設定DataGridする Web フォームです。 メソッドは PopulateGridDataGrid の呼び出しの結果 Discover を入力し、その後に への 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;
        
        // Only discover discovery documents, which might contain references to other types of discoverable documents.  
    doc = client.Discover(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
     ' Only discover discovery documents, which might contain references to other types of discoverable documents. 
     doc = client.Discover(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

注釈

メソッドは Discover 、指定された URL が検出ドキュメントであることを想定しています。 URL がサービスの説明または XML スキーマを参照している場合は、例外がスローされます。 XML スキーマまたはサービスの説明を検出するには、 メソッドを DiscoverAny 呼び出します。

指定された URL が有効な探索ドキュメントを指している場合、指定された URL にある探索ドキュメントが および References コレクションにDocuments追加されます。 さらに、探索ドキュメント内の参照はコレクションに References 追加されますが、有効な探索ドキュメントを指す検証は行われません。 参照を確認するには、有効な探索ドキュメントをポイントして メソッドまたは ResolveOneLevel メソッドをResolveAll呼び出します。

適用対象