DiscoveryClientProtocol.Documents Property

Gets a collection of discovery documents.

Namespace: System.Web.Services.Discovery
Assembly: System.Web.Services (in

public DiscoveryClientDocumentCollection Documents { get; }
/** @property */
public DiscoveryClientDocumentCollection get_Documents ()

public function get Documents () : DiscoveryClientDocumentCollection

Not applicable.

Property Value

A DiscoveryClientDocumentCollection representing the collection of discovery documents found.

The Documents collection is populated during invocations to the Discover, DiscoverAny, ResolveAll and ResolveOneLevel methods. During invocations to the Discover and DiscoverAny methods, if the supplied URL is a valid discovery document, that document is added to the Documents collection. During invocations to the ResolveAll and ResolveOneLevel methods, valid discovery document references in the References collection are added to the Documents collection.

The following code example is a Web Form that populates a DataGrid with the details about the documents in the Documents property discovered during XML Web services discovery. The PopulateGrid method fills the DataGrid with the results from a DiscoverAny invocation followed by a call to ResolveAll.

Security noteSecurity Note:

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio).

<%@ Page Language="C#" Debug="true" %>

<%@ Import Namespace="System.Web.Services.Discovery" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Data" %>

   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;

       	  DiscoveryDocument doc;
          // Discover the URL for any discoverable documents. 
	  doc = client.DiscoverAny(sourceUrl);
          // Resolve all possible references from the supplied URL.
        catch ( Exception e2) 
          Status.Text = e2.Message;
	// If documents were discovered, display the results in a data grid.
        if (client.Documents.Count > 0)

	// 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>";

      protected void PopulateGrid(DiscoveryClientProtocol client) 
         DataTable dt = new DataTable();
         DataRow dr;
         dt.Columns.Add(new DataColumn("Discovery Document") );
         dt.Columns.Add(new DataColumn("References") );
         dt.Columns.Add(new DataColumn("Type") );

	 // Iterate over the discovered documents, displaying their types and any associated references.
         foreach (DictionaryEntry entry in client.Documents) 
                dr = dt.NewRow();
  		dr[0] = (string) entry.Key;
		dr[2] = entry.Value.GetType();
		// If the discovered document is a discovery document, iterate over its references.	
		if (entry.Value is DiscoveryDocument)
	  	  DiscoveryDocument discoDoc = (DiscoveryDocument) entry.Value;
		  foreach (DiscoveryReference discoref in discoDoc.References)
		    dr = dt.NewRow();
		    dr[1] = discoref.Url;
		    dr[2] = discoref.GetType();
        DataView dv = new DataView(dt);
	DiscoveryResultsGrid.DataSource = (ICollection) dv;
	<H3> <p align="center"> Discovery Class Sample </p> </H3>
	 Enter the URL to discover:
        <asp:textbox id=DiscoURL Columns=60 runat="SERVER" /><p>

        Enter the directory to Read/Save the Discovery results:
        <asp:textbox id=DiscoDir runat="SERVER" /> <p>

	<p align="center"> <asp:Button id=Discover Text="Discover!" onClick="Discover_Click" runat="SERVER"/> </p><p>

        <asp:label id="Status" runat="SERVER" /><p>
     <asp:DataGrid id="DiscoveryResultsGrid"

         <HeaderStyle BackColor="DarkBlue" ForeColor="White">

         <AlternatingItemStyle BackColor="LightYellow">


Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0