DiscoveryClientProtocol.DiscoverAny(String) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menemukan URL yang disediakan untuk menentukan apakah itu adalah dokumen penemuan, deskripsi layanan, atau skema Definisi Skema 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
Parameter
- url
- String
URL tempat penemuan layanan Web XML dimulai.
Mengembalikan
Yang DiscoveryDocument berisi hasil penemuan layanan Web XML di URL yang disediakan.
url Jika parameter mengacu pada deskripsi layanan atau Skema XSD, dibuat DiscoveryDocument dalam memori untuk itu.
Pengecualian
Mengakses URL yang disediakan mengembalikan kode status HTTP selain OK.
Parameter url adalah URL yang valid, tetapi tidak menunjuk ke dokumen penemuan, deskripsi layanan, atau skema XSD yang valid.
Contoh
Contoh kode berikut adalah Formulir Web yang mengisi DataGrid dengan detail tentang dokumen di Documents properti bersama dengan referensi yang ditemukan di setiap dokumen selama penemuan layanan Web XML. Metode PopulateGrid mengisi DataGrid dengan hasil dari DiscoverAny pemanggilan diikuti dengan panggilan ke 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;
// 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
Keterangan
Metode ini DiscoverAny menemukan apakah URL yang disediakan adalah dokumen penemuan, deskripsi layanan, atau skema XSD. Jika diketahui bahwa URL hanya mengacu pada dokumen penemuan, Discover metode mungkin dipanggil.
Jika URL yang disediakan menunjuk ke dokumen penemuan, skema XSD, atau deskripsi layanan yang valid, dokumen penemuan di URL yang disediakan ditambahkan ke Documents koleksi dan References . Ketika URL yang disediakan mengacu pada skema XSD atau Deskripsi Layanan, DiscoveryDocument a dibuat dalam memori dan ditambahkan ke Documents koleksi dan References . Selain itu, referensi dalam dokumen penemuan ditambahkan ke References koleksi, tetapi tidak diverifikasi untuk menunjuk ke dokumen penemuan yang valid. Untuk memverifikasi bahwa referensi menunjuk ke dokumen penemuan yang ResolveAll valid, panggil metode atau ResolveOneLevel .