Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DiscoveryClientProtocol.References Property

A collection of references founds in resolved discovery documents.

Namespace: System.Web.Services.Discovery
Assembly: System.Web.Services (in system.web.services.dll)
public DiscoveryClientReferenceCollection References { get; }
/** @property */
public DiscoveryClientReferenceCollection get_References ()

public function get References () : DiscoveryClientReferenceCollection

Not applicable.

Property Value

A DiscoveryClientReferenceCollection of references discovered.

The References 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 References collection together with references found in the discovery document. References added during invocations to the Discover and DiscoverAny methods are not necessarily valid discovery documents. During invocations to ResolveAll and ResolveOneLevel references within the References collection are verified as being valid discovery documents. If they are valid and contain references, they are also added to the References collection.

The following code example is a Web Form that populates a DataGrid with the details about the references in the References property discovered during an XML Web services discovery. The PopulateGrid method fills the DataGrid with the references found in an invocation to DiscoverAny.

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" %>

<HTML>
<HEAD>
   <SCRIPT RUNAT="SERVER">
   protected void Discover_Click(object Source, EventArgs e)
   {
	// Specify the URL to discover.
	string sourceUrl = DiscoURL.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);
        }
        catch ( Exception e2) 
        {
          DiscoveryResultsGrid.Columns.Clear();
          Status.Text = e2.Message;
        }
	// If the discovered document contained, references display them in a data grid.
        if (client.References.Count > 0)
	    PopulateGrid(client);
   }

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

	 // Iterate over the references in the discovered document, displaying their type.
         foreach (DictionaryEntry entry in client.References) 
         {
                dr = dt.NewRow();
  		dr[0] = (string) entry.Key;
		dr[1] = entry.Value.GetType();
		dt.Rows.Add(dr);
         }
        DataView dv = new DataView(dt);
	DiscoveryResultsGrid.DataSource = (ICollection) dv;
	DiscoveryResultsGrid.DataBind();
      
    }
  </SCRIPT>
  </HEAD> 
  <BODY>
	<H3> <p align="center"> Discovery Class Sample </p> </H3>
        <FORM RUNAT="SERVER">
	<hr>	
	 Enter the URL to discover:
        <asp:textbox id=DiscoURL Columns=60 runat="SERVER" /><p>

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

        <hr>
        <asp:label id="Status" runat="SERVER" /><p>
     <asp:DataGrid id="DiscoveryResultsGrid"
           BorderColor="black"
           BorderWidth="1"
           CellPadding="3"
           AutoGenerateColumns="true"
           runat="server">

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

         <AlternatingItemStyle BackColor="LightYellow">
         </AlternatingItemStyle>

     </asp:DataGrid>
        </FORM>
  </BODY>

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.