다음을 통해 공유


DiscoveryClientProtocol.References 속성

정의

확인된 검색 문서에서 찾은 참조의 컬렉션입니다.

public:
 property System::Web::Services::Discovery::DiscoveryClientReferenceCollection ^ References { System::Web::Services::Discovery::DiscoveryClientReferenceCollection ^ get(); };
public System.Web.Services.Discovery.DiscoveryClientReferenceCollection References { get; }
member this.References : System.Web.Services.Discovery.DiscoveryClientReferenceCollection
Public ReadOnly Property References As DiscoveryClientReferenceCollection

속성 값

DiscoveryClientReferenceCollection

검색된 참조의 DiscoveryClientReferenceCollection입니다.

예제

다음 코드 예제는 XML 웹 서비스 검색 중에 검색된 속성의 참조 References 에 대한 세부 정보로 채워지는 DataGrid 웹 양식입니다. 메서드는 PopulateGrid 호출에서 DataGrid 찾은 참조를 입력합니다 DiscoverAny.

중요

이 예제에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력 내용에 스크립트 또는 HTML 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.

<%@ 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>
<%@ Page Language="VB" Debug="true" %>

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

<HTML>
<HEAD>
   <SCRIPT RUNAT="SERVER">

   Public Sub Discover_Click(Source As Object, e as EventArgs )
      ' Specify the URL to discover.
      Dim sourceUrl as String = DiscoURL.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)

       Catch e2 As Exception
          DiscoveryResultsGrid.Columns.Clear()
          Status.Text = e2.Message
       End Try

       ' If the discovered document contained references, display them in a data grid.
       If (client.References.Count > 0) Then
            'populate our Grid with the discovery results
        PopulateGrid(client)
       End If

  End Sub

  Public Sub PopulateGrid(client As DiscoveryClientProtocol) 
    Dim dt As DataTable = new DataTable()
    Dim dr AS DataRow 
 
    dt.Columns.Add(new DataColumn("Reference") )
    dt.Columns.Add(new DataColumn("Type") )

    Dim entry As DictionaryEntry
     
    ' Iterate over the references in the discovered document, displaying their type.
    For Each entry in client.References
       dr = dt.NewRow()
       dr(0) = entry.Key
       dr(1) = entry.Value.GetType()
       dt.Rows.Add(dr)
    Next 	
        
    Dim dv As DataView = new DataView(dt)
    DiscoveryResultsGrid.DataSource = dv
    DiscoveryResultsGrid.DataBind()
  End Sub
  </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>

설명

컬렉션은 References , DiscoverAnyResolveAllResolveOneLevel 메서드를 호출하는 Discover동안 채워집니다. 및 DiscoverAny 메서드를 호출하는 Discover 동안 제공된 URL이 유효한 검색 문서인 경우 해당 문서는 검색 문서에 있는 참조와 함께 컬렉션에 추가 References 됩니다. 및 메서드를 호출하는 Discover DiscoverAny 동안 추가된 참조가 반드시 유효한 검색 문서가 아닌 것은 아닙니다. 컬렉션에 호출하는 ResolveAll 동안 및 ResolveOneLevel 컬렉션 내의 References 참조는 유효한 검색 문서로 확인됩니다. 유효하고 참조를 포함하는 경우 컬렉션에도 References 추가됩니다.

적용 대상