HttpWebClientProtocol クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)

<ComVisibleAttribute(True)> _ Public MustInherit Class HttpWebClientProtocol Inherits WebClientProtocol
[ComVisibleAttribute(true)] public ref class HttpWebClientProtocol abstract : public WebClientProtocol

このクラスのプロパティを使用して、XML Web サービス要求および応答を送信するために使用する HTTP 要求オブジェクトの動作を制御します。このプロパティは、HttpWebRequest のプロパティに割り当てられます。
HTTP を使用して XML Web サービスと通信する場合は、XML Web サービスで使用する HttpWebClientProtocol から間接または直接に派生するプロキシ クラスを作成する必要があります。プロキシ クラスを手動で作成する代わりに、Wsdl.exe ツールを使用して、指定された XML Web サービスのサービスの説明からプロキシ クラスを作成できます。
HttpWebClientProtocol はすべてのプロキシ クラスの基本クラスであるため、そのプロパティと作成したプロキシ クラスのプロパティは同じになります。これらのプロパティは、基になるトランスポートの要求動作を制御するために役立ちます。たとえば、ファイアウォールをとおして XML Web サービスを呼び出すには、Proxy プロパティを使用します。これらの多数のプロパティは、Web 要求を行う HttpWebRequest の初期化に使用されます。
SoapHttpClientProtocol、HttpGetClientProtocol、および HttpPostClientProtocol は、HttpWebClientProtocol から直接的または間接的に派生して、それぞれ SOAP、HTTP-GET、および HTTP-POST をサポートします。

XML Web サービス (Math) を呼び出す ASP.NET Web フォームの例を次に示します。この Web フォームでは、EnterBtn_Click 関数の中で、サーバーがクライアントを他のサイトに自動的にリダイレクトできるようにします。また XML Web サービス メソッドを呼び出す前に、クライアント認証資格情報、プロキシ設定、要求のエンコーディング、および要求のタイムアウトを設定します。
<%@ 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>
<%@ 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>

System.MarshalByRefObject
System.ComponentModel.Component
System.Web.Services.Protocols.WebClientProtocol
System.Web.Services.Protocols.HttpWebClientProtocol
System.Web.Services.Discovery.DiscoveryClientProtocol
System.Web.Services.Protocols.HttpSimpleClientProtocol
System.Web.Services.Protocols.SoapHttpClientProtocol

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHttpWebClientProtocol クラスを検索する場合は、下記のリンクをクリックしてください。

- HttpWebClientProtocol クラスのページへのリンク