다음을 통해 공유


DiscoveryClientProtocol.DiscoverAny(String) 메서드

정의

제공된 URL이 검색 문서인지, 서비스 설명인지, XSD(XML Schema Definition) 스키마인지 확인하기 위해 이 URL을 검색합니다.

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

매개 변수

url
String

XML Web services 검색이 시작되는 URL입니다.

반환

DiscoveryDocument

제공된 URL에서 XML Web services 검색을 통해 가져온 결과를 포함하는 DiscoveryDocument입니다. url 매개 변수가 서비스 설명이나 XSD 스키마를 참조하면 DiscoveryDocument가 메모리에 생성됩니다.

예외

제공된 URL에 액세스했을 때 OK가 아닌 다른 HTTP 상태 코드가 반환되는 경우

url 매개 변수는 유효한 URL이지만 유효한 검색 문서, 서비스 설명 또는 XSD 스키마를 가리키지 않습니다.

예제

다음 코드 예제는 XML 웹 서비스를 검색하는 동안 각 문서에 있는 Documents 참조와 함께 속성의 문서에 대한 세부 정보로 채우는 DataGrid 웹 양식입니다. 메서드는 PopulateGrid 호출의 결과 DiscoverAny 와 다음에 ResolveAll호출을 채웁니다DataGrid.

 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 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

설명

이 메서드는 DiscoverAny 제공된 URL이 검색 문서, 서비스 설명 또는 XSD 스키마인지 여부를 검색합니다. URL이 검색 문서만 참조하는 것으로 알려진 경우 메서드가 Discover 호출될 수 있습니다.

제공된 URL이 유효한 검색 문서, XSD 스키마 또는 서비스 설명을 가리키는 경우 제공된 URL의 검색 문서가 컬렉션에 References 추가 Documents 됩니다. 제공된 URL이 XSD 스키마 또는 서비스 설명을 참조하는 경우 DiscoveryDocument 메모리에 만들어지고 컬렉션에 Documents References 추가됩니다. 또한 검색 문서 내의 참조는 컬렉션에 References 추가되지만 유효한 검색 문서를 가리키는 것으로 확인되지는 않습니다. 참조가 유효한 검색 문서를 가리키는지 확인하려면 또는 ResolveOneLevel 메서드를 ResolveAll 호출합니다.

적용 대상