DiscoveryClientProtocol 클래스

정의

프로그래밍 방식으로 XML Web services를 검색할 수 있도록 지원합니다.

public ref class DiscoveryClientProtocol : System::Web::Services::Protocols::HttpWebClientProtocol
public class DiscoveryClientProtocol : System.Web.Services.Protocols.HttpWebClientProtocol
type DiscoveryClientProtocol = class
    inherit HttpWebClientProtocol
Public Class DiscoveryClientProtocol
Inherits HttpWebClientProtocol
상속

예제

다음 코드 예제는 클래스를 네임스페이 DiscoveryClientProtocol 스의 System.Web.Services.Discovery 다른 클래스와 함께 사용하여 프로그래밍 방식으로 XML 웹 서비스 검색을 호출하는 방법을 보여 주는 웹 양식입니다. 코드 예제에서는 , , , , ResolveAll및 메서드를 Discover사용하는 방법을 보여 줍니다WriteAll. ReadAllResolveOneLevelDiscoverDiscoverAny

중요

이 예제에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 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;
    // 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;
      // Check to see if whether the user wanted to read in existing discovery results.
      if (DiscoverMode.Value == "ReadAll") 
          {
         DiscoveryClientResultCollection results = client.ReadAll(Path.Combine(DiscoDir.Text,"results.discomap"));
            SaveMode.Value = "NoSave";						
      }
      else 
          {
        // Check to see if whether the user wants the capability to discover any kind of discoverable document.
        if (DiscoverMode.Value == "DiscoverAny") 
            {
          doc = client.DiscoverAny(sourceUrl);
            }
        else
        // Discover only discovery documents, which might contain references to other types of discoverable documents.
            {
          doc = client.Discover(sourceUrl);
        }
        // Check to see whether the user wants to resolve all possible references from the supplied URL.
        if (ResolveMode.Value == "ResolveAll")
           client.ResolveAll();
        else 
            {
        // Check to see whether the user wants to resolve references nested more than one level deep.
            if (ResolveMode.Value == "ResolveOneLevel")  
               client.ResolveOneLevel();
            else
           Status.Text = String.Empty;
            }
          }
        }
        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);

    // If the user also asked to have the results saved to the Web server, do so.
        if (SaveMode.Value == "Save") 
        {
          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"));


         foreach (DictionaryEntry entry in client.Documents) 
         {
                dr = dt.NewRow();
        dr[0] = (string) entry.Key;
        dr[2] = entry.Value.GetType();
        dt.Rows.Add(dr);
        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();
            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>

       Discovery Mode:
       <select id="DiscoverMode" size=1 runat="SERVER">
         <option Value="DiscoverAny">Discover any of the discovery types</option>
             <option Value="Discover">Discover just discovery documents</option>
             <option Value="ReadAll">Read in saved discovery results</option>
    </select> <p>

       Resolve References Mode:
       <select id="ResolveMode" size=1 runat="SERVER">
             <option Value="ResolveAll">Resolve all references</option>
             <option Value="ResolveOneLevel">Resolve references only in discovery documents within the supplied URL</option>
             <option Value="ResolveNone">Do not resolve references</option>
    </select> <p>
        
       Save Results Mode:
    <select id="SaveMode" size=1 runat="SERVER">
         <option Value="NoSave">Do not save any of the discovery documents found locally</option>
             <option Value="Save">Save the discovery documents found locally</option>
        </select> <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>

        <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
      ' 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
        ' Check to see whether the user wanted to read in existing discovery results.
    If (DiscoverMode.Value = "ReadAll") Then
       Dim results As DiscoveryClientResultCollection 
           results = client.ReadAll(Path.Combine(DiscoDir.Text,"results.discomap"))
       SaveMode.Value = "NoSave"						
    Else
       ' Check to see whether the user user wants the capability to discover any kind of discoverable document.
           If (DiscoverMode.Value = "DiscoverAny") Then
         doc = client.DiscoverAny(sourceUrl)
           Else
         ' Discover only discovery documents, which might contain references to other types of discoverable documents. 
         doc = client.Discover(sourceUrl)
       End If
           
           ' Check to see whether the user wants to resolve all possible references from the supplied URL.
       If (ResolveMode.Value = "ResolveAll") Then
          client.ResolveAll()
           ' Check to see whether the user wants to resolve references nested more than one level deep.
       ElseIf (ResolveMode.Value = "ResolveOneLevel")  Then
              client.ResolveOneLevel()
       Else
          Status.Text = String.Empty
           End If
    End If
            
       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 our Grid with the discovery results.
        PopulateGrid(client)
       End If

       ' If the user also asked to have the results saved to the Web server, do so.	    
       If (SaveMode.Value = "Save") Then
      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 If                             

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

     Dim entry As DictionaryEntry
         For Each entry in client.Documents
            dr = dt.NewRow()
        dr(0) = entry.Key
        dr(2) = entry.Value.GetType()
        dt.Rows.Add(dr)
        If TypeOf entry.Value Is DiscoveryDocument Then
           Dim discoDoc As DiscoveryDocument = entry.Value
           Dim discoref As DiscoveryReference
           For Each discoref in discoDoc.References
          dr = dt.NewRow()
          dr(1) = discoref.Url
          dr(2) = discoref.GetType()
          dt.Rows.Add(dr)
           Next
        End If   
    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>

       Discovery Mode:
       <select id="DiscoverMode" size=1 runat="SERVER">
         <option Value="DiscoverAny">Discover any of the discovery types</option>
             <option Value="Discover">Discover just discovery documents</option>
             <option Value="ReadAll">Read in saved discovery results</option>
    </select> <p>

       Resolve References Mode:
       <select id="ResolveMode" size=1 runat="SERVER">
          <option Value="ResolveAll">Resolve all references</option>
             <option Value="ResolveOneLevel">Resolve references only in discovery documents within the supplied URL</option>
             <option Value="ResolveNone">Do not resolve references</option>
    </select> <p>
        
       Save Results Mode:
    <select id="SaveMode" size=1 runat="SERVER">
          <option Value="NoSave">Do not save any of the discovery documents found locally</option>
             <option Value="Save">Save the discovery documents found locally</option>
        </select> <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>

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

설명

XML 웹 서비스 검색은 사용 가능한 XML 웹 서비스를 설명하는 하나 이상의 관련 문서를 찾거나 검색하는 프로세스입니다. XML 웹 서비스 클라이언트는 XML 웹 서비스 검색을 통해 지정된 URL에서 사용 가능한 XML 웹 서비스 및 사용 방법에 대해 알아봅니다. XML 웹 서비스 검색은 디렉터리 서비스를 통해 검색 문서에 대한 URL을 이미 가져온 전제에서 작동합니다. 그러나 제공되는 XML 웹 서비스에 대한 세부 정보는 없습니다. XML 웹 서비스 검색을 통해 특정 URL에서 에 나열된 DiscoveryDocument XML 웹 서비스에 대한 세부 정보를 검색할 수 있습니다.

XML 웹 서비스 클라이언트는 또는 DiscoverAny 메서드에 URL을 제공하여 XML 웹 서비스 검색을 Discover 시작합니다. 일반적으로 이 URL은 검색 문서를 참조하며, 이 문서는 속성에 추가 References 되는 하나 이상의 XML 웹 서비스를 설명하는 문서를 참조합니다. 이 시점에서 해당 문서만 다운로드되고 XML 웹 서비스에 대한 유효한 정보를 가리키도록 확인됩니다. 그러나 해당 문서에 포함된 참조는 이 단계에서 확인되지 않습니다. 대신 속성에 References 추가됩니다. 참조가 유효한지 확인하려면 또는 ResolveOneLevel 메서드를 ResolveAll 호출하여 속성에 유효한 참조 문서를 Documents 추가합니다. 마지막으로, 클라이언트가 검색 결과를 디스크에 저장하려는 경우 메서드를 호출합니다 WriteAll .

XML 웹 서비스 검색에 프로그래밍 방식으로 액세스할 필요가 없는 경우 Windows SDK는 명령 프롬프트 내에서 XML 웹 서비스를 검색하기 위한 웹 서비스 검색 도구(Disco.exe)를 제공합니다. 자세한 내용은 웹 서비스 검색 도구(Disco.exe)를 참조하세요.

생성자

DiscoveryClientProtocol()

DiscoveryClientProtocol 클래스의 새 인스턴스를 초기화합니다.

속성

AdditionalInformation

검색 문서에서 찾은 참조와 함께 정보를 가져옵니다.

AllowAutoRedirect

클라이언트가 서버 리디렉션을 자동으로 따르는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 HttpWebClientProtocol)
CanRaiseEvents

구성 요소가 이벤트를 발생시킬 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
ClientCertificates

클라이언트 인증서의 컬렉션을 가져옵니다.

(다음에서 상속됨 HttpWebClientProtocol)
ConnectionGroupName

요청에 대한 연결 그룹의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 WebClientProtocol)
Container

IContainer을 포함하는 Component를 가져옵니다.

(다음에서 상속됨 Component)
CookieContainer

쿠키의 컬렉션을 가져오거나 설정합니다.

(다음에서 상속됨 HttpWebClientProtocol)
Credentials

XML Web services 클라이언트 인증의 보안 자격 증명을 가져오거나 설정합니다.

(다음에서 상속됨 WebClientProtocol)
DesignMode

Component가 현재 디자인 모드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
Documents

검색 문서의 컬렉션을 가져옵니다.

EnableDecompression

HttpWebClientProtocol에 대해 압축 해제가 사용되는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 HttpWebClientProtocol)
Errors

이 클래스에서 메서드를 호출하는 동안 발생한 예외의 컬렉션을 가져옵니다.

Events

Component에 연결된 이벤트 처리기의 목록을 가져옵니다.

(다음에서 상속됨 Component)
PreAuthenticate

사전 인증을 활성화할지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 WebClientProtocol)
Proxy

방화벽을 통해 XML Web services를 요청하기 위한 프록시 정보를 가져오거나 설정합니다.

(다음에서 상속됨 HttpWebClientProtocol)
References

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

RequestEncoding

XML Web services에 클라이언트 요청을 하는 데 사용되는 Encoding입니다.

(다음에서 상속됨 WebClientProtocol)
Site

ComponentISite를 가져오거나 설정합니다.

(다음에서 상속됨 Component)
Timeout

동기 XML Web services 요청에 대한 응답이 도착하기까지 대기하는 시간(밀리초)을 나타냅니다.

(다음에서 상속됨 WebClientProtocol)
UnsafeAuthenticatedConnectionSharing

클라이언트가 NTLM 인증을 사용하여 XML Web services가 호스팅되는 웹 서버에 연결하는 데 연결 공유가 사용되는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 HttpWebClientProtocol)
Url

클라이언트에서 요청 중인 XML Web services의 기본 URL을 가져오거나 설정합니다.

(다음에서 상속됨 WebClientProtocol)
UseDefaultCredentials

Credentials 속성을 DefaultCredentials 속성 값으로 설정할지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 WebClientProtocol)
UserAgent

각 요청과 함께 보내지는 사용자 에이전트 헤더에 대한 값을 가져오거나 설정합니다.

(다음에서 상속됨 HttpWebClientProtocol)

메서드

Abort()

XML Web services 메서드에 대한 요청을 취소합니다.

(다음에서 상속됨 WebClientProtocol)
CancelAsync(Object)

호출이 아직 완료되지 않은 경우 XML Web services 메서드에 대한 비동기적 호출을 취소합니다.

(다음에서 상속됨 HttpWebClientProtocol)
CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Discover(String)

제공된 URL이 검색 문서인지 여부를 확인하기 위해 해당 URL을 검색합니다.

DiscoverAny(String)

제공된 URL이 검색 문서인지, 서비스 설명인지, XSD(XML Schema Definition) 스키마인지 확인하기 위해 이 URL을 검색합니다.

Dispose()

Component에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Component)
Dispose(Boolean)

Component에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

(다음에서 상속됨 Component)
Download(String)

제공된 URL에 있는 검색 문서를 Stream 개체로 다운로드합니다.

Download(String, String)

contentType 매개 변수를 검색 문서의 MIME 인코딩으로 설정하여 제공된 URL에 있는 검색 문서를 Stream 개체로 다운로드합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetService(Type)

Component 또는 해당 Container에서 제공하는 서비스를 나타내는 개체를 반환합니다.

(다음에서 상속됨 Component)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
GetWebRequest(Uri)

지정된 URI에 대해 WebRequest를 만듭니다.

(다음에서 상속됨 HttpWebClientProtocol)
GetWebResponse(WebRequest)

XML Web services 메서드에 대한 동기 요청에서 응답을 반환합니다.

(다음에서 상속됨 HttpWebClientProtocol)
GetWebResponse(WebRequest, IAsyncResult)

XML Web services 메서드에 대한 비동기 요청에서 응답을 반환합니다.

(다음에서 상속됨 HttpWebClientProtocol)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
LoadExternals()
사용되지 않음.

외부 참조를 로드하도록 DiscoveryClientProtocol 개체에 지시합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ReadAll(String)

검색 문서, XSD(XML Schema Definition) 스키마, 파일에서 참조되는 서비스 설명으로 DocumentsReferences 속성을 채우는 저장된 검색 문서의 맵이 포함되어 있는 파일에서 읽습니다.

ResolveAll()

참조된 검색 문서에서 찾은 참조뿐만 아니라 References 속성에 있는 검색 문서, XSD(XML Schema Definition) 스키마 및 서비스 설명에 대한 모든 참조도 확인합니다.

ResolveOneLevel()

해당 검색 문서에서 찾은 참조뿐만 아니라 References에 있는 검색 문서, XSD(XML Schema Definition) 스키마 및 서비스 설명에 대한 모든 참조도 확인합니다.

ToString()

Component의 이름이 포함된 String을 반환합니다(있는 경우). 이 메서드는 재정의할 수 없습니다.

(다음에서 상속됨 Component)
WriteAll(String, String)

Documents 속성에 있는 모든 검색 문서, XSD(XML Schema Definition) 스키마 및 서비스 설명을 제공된 디렉터리에 쓰고 이 디렉터리에 파일을 만듭니다.

이벤트

Disposed

Dispose() 메서드를 호출하여 구성 요소를 삭제할 때 발생합니다.

(다음에서 상속됨 Component)

적용 대상

추가 정보