HttpWebClientProtocol Class

The base class for all XML Web service client proxies that use the HTTP transport protocol.

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

<ComVisibleAttribute(True)> _
Public MustInherit Class HttpWebClientProtocol _
	Inherits WebClientProtocol
Dim instance As HttpWebClientProtocol

The properties on this class are used to control the behavior of the HTTP request object used to transmit the XML Web service request and response. The properties map to properties found on HttpWebRequest.

To communicate with an XML Web service using HTTP, you must create a proxy class deriving indirectly or directly from HttpWebClientProtocol for the XML Web service. Instead of creating the proxy class manually, you can use the Wsdl.exe tool to create a proxy class for a given XML Web service's service description.

Since HttpWebClientProtocol is the base class for all proxy classes, its properties are on your proxy classes. These properties are useful for controlling the request behavior of the underlying transport. For example, use the Proxy property for calling XML Web services through a firewall. Many of these properties are used to initialize the HttpWebRequest that makes the Web request.

SoapHttpClientProtocol, HttpGetClientProtocol, and HttpPostClientProtocol derive directly or indirectly from HttpWebClientProtocol to provide support for SOAP, HTTP-GET and HTTP-POST respectively.

The following example is an ASP.NET Web Form, which calls an XML Web service named Math. Within the EnterBtn_Click function, the Web Form allows the server to automatically redirect the client to other sites. It also sets client authentication credentials, proxy settings, the request encoding and the time out for the request before calling the XML Web service method.

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

    <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), _
        Total.Text = "Total: " & iTotal.ToString()
    End Sub


       <form action="MathClient.aspx" runat=server>

          Enter the two numbers you want to add and then press the Total button.
          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/>
          <asp:label id="Total"  runat=server/>


The properties on this class are copied into a new instance of a WebRequest object for each XML Web service method call. While you can call XML Web service methods on the same WebClientProtocol instance from different threads at the same time, there is no synchronization done to ensure that a consistent snapshot of the properties gets transferred to the WebRequest object. Therefore, if you need to modify the properties and make concurrent method calls from different threads you should use a different instance of the XML Web service proxy or provide your own synchronization.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0