HttpWebClientProtocol クラス

定義

HTTP トランスポート プロトコルを使用するすべての XML Web サービス クライアント プロキシの基本クラスを表します。

public ref class HttpWebClientProtocol abstract : System::Web::Services::Protocols::WebClientProtocol
public abstract class HttpWebClientProtocol : System.Web.Services.Protocols.WebClientProtocol
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class HttpWebClientProtocol : System.Web.Services.Protocols.WebClientProtocol
type HttpWebClientProtocol = class
    inherit WebClientProtocol
[<System.Runtime.InteropServices.ComVisible(true)>]
type HttpWebClientProtocol = class
    inherit WebClientProtocol
Public MustInherit Class HttpWebClientProtocol
Inherits WebClientProtocol
継承
派生
属性

次の例は、 という名前 Mathの XML Web サービスを呼び出す ASP.NET Web フォームです。 関数内では EnterBtn_Click 、Web フォームを使用すると、サーバーはクライアントを他のサイトに自動的にリダイレクトできます。 また、XML Web サービス メソッドを呼び出す前に、クライアント認証資格情報、プロキシ設定、要求エンコード、および要求のタイムアウトも設定します。

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net" %>

<html>
    <script language="C#" runat="server">
       void EnterBtn_Click(Object Src, EventArgs E) 
          {
             MyMath.Math math = new MyMath.Math();

             // Allow the server to redirect the request.
             math.AllowAutoRedirect = true;

             // Set the client-side credentials using the Credentials property.
             ICredentials credentials =
                new NetworkCredential("Joe","password","mydomain");
             math.Credentials = credentials;

             // Set the proxy server to proxyserver, set the port to 80, and specify to bypass
             // the proxy server for local addresses.
             IWebProxy proxyObject = new WebProxy("http://proxyserver:80",true);
             math.Proxy = proxyObject;

             // Set the encoding to utf-8.
             math.RequestEncoding = System.Text.Encoding.UTF8;

             // Set the time out to 15 seconds
             math.Timeout = 15000;

             int total = math.Add(Convert.ToInt32(Num1.Text),
                Convert.ToInt32(Num2.Text));
             Total.Text = "Total: " + total.ToString();
         }
 
    </script>
 
    <body>
       <form action="MathClient.aspx" runat=server>
           
          Enter the two numbers you want to add and then press the Total button.
          <p>
          Number 1: <asp:textbox id="Num1" runat=server/>  +
          Number 2: <asp:textbox id="Num2" runat=server/> =
          <asp:button text="Total" Onclick="EnterBtn_Click" runat=server/>
          <p>
          <asp:label id="Total"  runat=server/>
          
       </form>
    </body>
 </html>
   
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Net" %>

<html>
    <script language="VB" runat="server">

    Sub EnterBtn_Click(Src As Object, E As EventArgs)
        Dim math As New MyMath.Math()
        
        ' Allow the server to redirect the request.
        math.AllowAutoRedirect = True
        
        ' Set the client-side credentials using the Credentials property.
        Dim credentials = New NetworkCredential("Joe", "password", "mydomain")
        math.Credentials = credentials
        
        ' Set the proxy server to proxyserver, set the port to 80 and specify to bypass
        ' the proxy server for local addresses.
        Dim proxyObject = New WebProxy("http://proxyserver:80", True)
        math.Proxy = proxyObject
        
        ' Set the encoding to utf-8.
        math.RequestEncoding = System.Text.Encoding.UTF8
        
        ' Set the time out to 15 seconds.
        math.Timeout = 15000
        
        Dim iTotal As Integer = math.Add(Convert.ToInt32(Num1.Text), _
           Convert.ToInt32(Num2.Text))
        Total.Text = "Total: " & iTotal.ToString()
    End Sub
 
    </script>
 
    <body>
       <form action="MathClient.aspx" runat=server>
           
          Enter the two numbers you want to add and then press the Total button.
          <p>
          Number 1: <asp:textbox id="Num1" runat=server/>  +
          Number 2: <asp:textbox id="Num2" runat=server/> =
          <asp:button text="Total" Onclick="EnterBtn_Click" runat=server/>
          <p>
          <asp:label id="Total"  runat=server/>
          
       </form>
    </body>
 </html>
   

注釈

このクラスのプロパティは、XML Web サービスの要求と応答の送信に使用される HTTP 要求オブジェクトの動作を制御するために使用されます。 プロパティは、 で見つかったプロパティにマップされます HttpWebRequest

HTTP を使用して XML Web サービスと通信するには、XML Web サービスに対して間接的に、または から HttpWebClientProtocol 直接派生するプロキシ クラスを作成する必要があります。 プロキシ クラスを手動で作成する代わりに、Wsdl.exe ツールを使用して、特定の XML Web サービスのサービス記述のプロキシ クラスを作成できます。

HttpWebClientProtocol はすべてのプロキシ クラスの基底クラスであるため、そのプロパティはプロキシ クラスにあります。 これらのプロパティは、基になるトランスポートの要求動作を制御するのに役立ちます。 たとえば、 プロパティを Proxy 使用して、ファイアウォールを介して XML Web サービスを呼び出します。 これらのプロパティの多くは、Web 要求を行う を HttpWebRequest 初期化するために使用されます。

SoapHttpClientProtocolHttpGetClientProtocol、および HttpPostClientProtocol から HttpWebClientProtocol 直接または間接的に派生して、それぞれ SOAP、HTTP-GET、HTTP-POST のサポートを提供します。

コンストラクター

HttpWebClientProtocol()

HttpWebClientProtocol クラスの新しいインスタンスを初期化します。

プロパティ

AllowAutoRedirect

クライアントがサーバーのリダイレクトに自動的に従うかどうかを取得または設定します。

CanRaiseEvents

コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。

(継承元 Component)
ClientCertificates

クライアント証明書のコレクションを取得します。

ConnectionGroupName

要求に対して使用する接続グループの名前を取得または設定します。

(継承元 WebClientProtocol)
Container

IContainer を含む Component を取得します。

(継承元 Component)
CookieContainer

クッキーのコレクションを取得または設定します。

Credentials

XML Web サービス クライアント認証のセキュリティ資格情報を取得または設定します。

(継承元 WebClientProtocol)
DesignMode

Component が現在デザイン モードかどうかを示す値を取得します。

(継承元 Component)
EnableDecompression

この HttpWebClientProtocol の圧縮解除が有効かどうかを示す値を取得または設定します。

Events

Component に結び付けられているイベント ハンドラーのリストを取得します。

(継承元 Component)
PreAuthenticate

事前認証を有効にするかどうかを取得または設定します。

(継承元 WebClientProtocol)
Proxy

ファイアウォールをとおして XML Web サービス要求を行うためのプロキシ情報を取得または設定します。

RequestEncoding

クライアントが XML Web サービスを要求するときに使用される Encoding

(継承元 WebClientProtocol)
Site

ComponentISite を取得または設定します。

(継承元 Component)
Timeout

同期的な XML Web サービスの要求に対する返答の受信を XML Web サービス クライアントが待機する時間 (ミリ秒単位) を示します。

(継承元 WebClientProtocol)
UnsafeAuthenticatedConnectionSharing

XML Web サービスをホストしている Web サービスに接続するときにクライアントが NTLM 認証を使用する場合、接続共有が有効になっているかどうかを示す値を取得または設定します。

Url

クライアントが要求している XML Web サービスのベース URL を取得または設定します。

(継承元 WebClientProtocol)
UseDefaultCredentials

Credentials プロパティを DefaultCredentials プロパティの値に設定するかどうかを示す値を取得または設定します。

(継承元 WebClientProtocol)
UserAgent

それぞれの要求と共に送信されるユーザー エージェント ヘッダーの値を取得または設定します。

メソッド

Abort()

XML Web サービス メソッドへの要求をキャンセルします。

(継承元 WebClientProtocol)
CancelAsync(Object)

呼び出しが完了済みの場合を除き、XML Web サービス メソッドの非同期呼び出しをキャンセルします。

CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Dispose()

Component によって使用されているすべてのリソースを解放します。

(継承元 Component)
Dispose(Boolean)

Component によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。

(継承元 Component)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GenerateXmlMappings(Type, ArrayList)

指定された型で公開される各 XML Web サービス メソッドの XmlMembersMapping を取得し、マップを指定された ArrayList に格納します。

GenerateXmlMappings(Type[], ArrayList)

指定された型で公開される各 XML Web サービス メソッドの XmlMembersMapping を取得し、マップを指定された ArrayList、およびこのメソッドから返される Hashtable に格納します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetLifetimeService()
古い.

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetService(Type)

Component またはその Container で提供されるサービスを表すオブジェクトを返します。

(継承元 Component)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
GetWebRequest(Uri)

指定した URI に対する WebRequest を作成します。

GetWebResponse(WebRequest)

XML Web サービス メソッドへの同期要求から応答を返します。

GetWebResponse(WebRequest, IAsyncResult)

XML Web サービス メソッドへの非同期要求から応答を返します。

InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
ToString()

Component の名前 (存在する場合) を格納する String を返します。 このメソッドはオーバーライドできません。

(継承元 Component)

イベント

Disposed

Dispose() メソッドの呼び出しによってコンポーネントが破棄されるときに発生します。

(継承元 Component)

適用対象

スレッド セーフ

このクラスのプロパティは、XML Web サービス メソッドの呼び出しごとに オブジェクトの WebRequest 新しいインスタンスにコピーされます。 異なるスレッドから同じ WebClientProtocol インスタンスで XML Web サービス メソッドを同時に呼び出すことができますが、プロパティの一貫性のあるスナップショットがオブジェクトに転送されるようにするために WebRequest 同期は行われません。 したがって、プロパティを変更し、異なるスレッドからメソッド呼び出しを同時に行う必要がある場合は、XML Web サービス プロキシの別のインスタンスを使用するか、独自の同期を提供する必要があります。

こちらもご覧ください