Share via


DiscoveryClientProtocol.DiscoverAny(String) Metoda

Definice

Vyhledá zadanou adresu URL a určí, jestli se jedná o dokument zjišťování, popis služby nebo schéma definice schématu XML (XSD).

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

Parametry

url
String

Adresa URL, kde začíná zjišťování webových služeb XML.

Návraty

Obsahující DiscoveryDocument výsledky zjišťování webových služeb XML na zadané adrese URL. url Pokud parametr odkazuje na popis služby nebo schéma XSD, DiscoveryDocument vytvoří se pro něj v paměti.

Výjimky

Přístup k zadané adrese URL vrátil jiný stavový kód HTTP než OK.

Parametr url je platná adresa URL, ale neodkazuje na platný dokument zjišťování, popis služby ani schéma XSD.

Příklady

Následující příklad kódu je webový formulář, který naplní DataGrid podrobnosti o dokumentech ve Documents vlastnosti spolu s odkazy nalezené v každém dokumentu během zjišťování webových služeb XML. Metoda PopulateGrid vyplní výsledky volání DiscoverAny následované voláním ResolveAllDataGrid .

 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

Poznámky

Metoda DiscoverAny zjistí, jestli je zadaná adresa URL dokument zjišťování, popis služby nebo schéma XSD. Pokud je známo, že adresa URL odkazuje pouze na dokument zjišťování, Discover může být vyvolána metoda .

Pokud zadaná adresa URL odkazuje na platný dokument zjišťování, schéma XSD nebo popis služby, dokument zjišťování na zadané adrese URL se přidá do Documents kolekcí a References . Pokud zadaná adresa URL odkazuje na schéma XSD nebo popis DiscoveryDocument služby, vytvoří se v paměti a přidá se do Documents kolekcí a References . Kromě toho se odkazy v rámci dokumentu zjišťování přidají do References kolekce, ale neověřují se, aby odkazovali na platné dokumenty zjišťování. Chcete-li ověřit, že odkazy odkazují na platné dokumenty zjišťování, vyvolejte ResolveAll metody nebo ResolveOneLevel .

Platí pro