DiscoveryClientProtocol.DiscoverAny(String) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Identifierar den angivna URL:en för att avgöra om det är ett identifieringsdokument, en tjänstbeskrivning eller ett XSD-schema (XML Schema Definition).
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
Parametrar
- url
- String
URL:en där XML-webbtjänstidentifieringen börjar.
Returer
En DiscoveryDocument som innehåller resultatet av XML-webbtjänstidentifiering på den angivna URL:en. Om parametern url refererar till en tjänstbeskrivning eller ett XSD-schema skapas en DiscoveryDocument i minnet för den.
Undantag
Åtkomsten till den angivna URL:en returnerade en annan HTTP-statuskod än OK.
Parametern url är en giltig URL, men pekar inte på ett giltigt identifieringsdokument, tjänstbeskrivning eller XSD-schema.
Exempel
Följande kodexempel är ett webbformulär som fyller i en DataGrid med information om dokumenten i Documents egenskapen tillsammans med de referenser som finns i varje dokument under en XML-webbtjänstidentifiering. Metoden PopulateGrid fyller DataGrid med resultatet från ett DiscoverAny anrop följt av ett anrop till 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
Kommentarer
Metoden DiscoverAny identifierar om den angivna URL:en är ett identifieringsdokument, en tjänstbeskrivning eller ett XSD-schema. Om det är känt att URL:en bara refererar till ett identifieringsdokument kan Discover metoden anropas.
Om den angivna URL:en pekar på ett giltigt identifieringsdokument, XSD-schema eller tjänstbeskrivning läggs identifieringsdokumentet på den angivna URL:en till i samlingarna Documents och References . När den angivna URL:en refererar till ett XSD-schema eller en DiscoveryDocument tjänstbeskrivning skapas i minnet och läggs till i samlingarna Documents och References . Dessutom läggs referenser i identifieringsdokumentet till i References samlingen, men verifieras inte för att peka på giltiga identifieringsdokument. Om du vill verifiera att referenser pekar på giltiga identifieringsdokument anropar du ResolveAll metoderna eller ResolveOneLevel .