DiscoveryClientProtocol クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DiscoveryClientProtocol クラスの意味・解説 

DiscoveryClientProtocol クラス

プログラムによる XML Web サービス探索呼び出しサポートします

名前空間: System.Web.Services.Discovery
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Public Class DiscoveryClientProtocol
    Inherits HttpWebClientProtocol
Dim instance As DiscoveryClientProtocol
public class DiscoveryClientProtocol : HttpWebClientProtocol
public ref class DiscoveryClientProtocol :
 public HttpWebClientProtocol
public class DiscoveryClientProtocol extends
 HttpWebClientProtocol
public class DiscoveryClientProtocol extends
 HttpWebClientProtocol
解説解説

XML Web サービス探索とは探索を行うプロセスであり、利用可能XML Web サービス記述している 1 つ上の関連ドキュメントの場所を確認しますXML Web サービス探索通じてXML Web サービス クライアント特定の URL利用できる XML Web サービス確認し、またそのサービス使い方確認しますXML Web サービス探索は、既にディレクトリ サービスなどを通じて http://uddi.microsoft.com などの探索ドキュメントへの URL取得していることを前提としていますが、提供される XML Web サービス詳細について知っておく必要はありません。XML Web サービス探索とおして指定 URL で DiscoveryDocument にリストされている XML Web サービスについての詳細探索できます

XML Web サービス クライアントURLDiscover メソッドまたは DiscoverAny メソッド指定することにより XML Web サービス探索開始します通常、この URL探索ドキュメント参照します。つまり、References プロパティ追加されている 1 つ上の XML Web サービス記述しているドキュメント参照します。この時点では、そのドキュメントだけがダウンロードされ、XML Web サービスについて有効な情報指しているかどうか検証されます。しかし、そのドキュメント格納される参照この段階ではまだ検証されません。その代わりに、参照References プロパティ追加されます。参照が有効かどうか検証するには、Documents プロパティ有効な参照ドキュメント追加する ResolveAll メソッドまたは ResolveOneLevel メソッド呼び出します。最後にクライアント探索結果ディスク保存する場合は、WriteAll メソッド呼び出します。

XML Web サービス探索へのプログラムによるアクセス必要な場合は、Microsoft .NET Framework SDK含まれている Web サービス検出ツール (Disco.exe) を使用してコマンド プロンプトから XML Web サービス探索行います詳細については、Web サービス検出ツール (Disco.exe) のトピック参照してください

使用例使用例

DiscoveryClientProtocol クラスと System.Web.Services.Discovery 名前空間にある他のクラス使用して XML Web サービス探索プログラムによって呼び出す Web フォームコード例次に示します。このコード例では DiscoverDiscoverAnyDiscoverResolveAllResolveOneLevel、ReadAllWriteAll の各メソッド使用してます。

<%@ 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>
<%@ 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>
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Web.Services.Protocols.WebClientProtocol
         System.Web.Services.Protocols.HttpWebClientProtocol
          System.Web.Services.Discovery.DiscoveryClientProtocol
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DiscoveryClientProtocol メンバ
System.Web.Services.Discovery 名前空間
DiscoveryDocument
ServiceDescription クラス
HttpWebClientProtocol



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DiscoveryClientProtocol クラス」の関連用語

DiscoveryClientProtocol クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DiscoveryClientProtocol クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS