Aracılığıyla paylaş


DiscoveryClientProtocol.Discover(String) Yöntem

Tanım

Bir bulma belgesi olup olmadığını belirlemek için sağlanan URL'yi bulur.

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

Parametreler

url
String

XML Web hizmetleri bulma işleminin başladığı URL.

Döndürülenler

DiscoveryDocument

DiscoveryDocument Sağlanan URL'de XML Web hizmetleri bulma sonuçlarını içeren.

Özel durumlar

Sağlanan URL'ye erişmek dışında OKbir HTTP durum kodu döndürdü.

url parametresi geçerli bir URL'dir, ancak geçerli bir bulma belgesine işaret etmez.

Örnekler

Aşağıdaki kod örneği, XML Web hizmetleri bulma sırasında her belgede bulunan başvurularla birlikte özelliğindeki Documents belgelerle ilgili ayrıntılarla dolduran DataGrid bir Web Formudur. yöntemi, PopulateGrid çağrısından ve ardından çağrısından ResolveAllelde edilen Discover sonuçlarla doldururDataGrid.

 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

Açıklamalar

yöntemi, Discover sağlanan URL'nin bir bulma belgesi olmasını bekler. URL bir hizmet açıklamasına veya XML şemasına başvuruyorsa bir özel durum oluşturulur. XML şemasını veya hizmet açıklamasını bulmak için yöntemini çağırın DiscoverAny .

Sağlanan URL geçerli bir bulma belgesine işaret ederse, sağlanan URL'deki bulma belgesi ve References koleksiyonuna Documents eklenir. Ayrıca, bulma belgesi içindeki başvurular koleksiyona References eklenir, ancak geçerli bulma belgelerini işaret etmek için doğrulanmaz. Başvuruları doğrulamak için, veya ResolveOneLevel yöntemlerini çağırmak için geçerli bulma belgelerinin ResolveAll üzerine gelin.

Şunlara uygulanır