Specifies the base class for all XML Web service client proxies created using ASP.NET.
For a list of all members of this type, see WebClientProtocol Members.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Web.Services.Protocols.WebClientProtocol
System.Web.Services.Protocols.HttpWebClientProtocol
[Visual Basic]
MustInherit Public Class WebClientProtocol
Inherits Component
[C#]
public abstract class WebClientProtocol : Component
[C++]
public __gc __abstract class WebClientProtocol : public Component
[JScript]
public abstract class WebClientProtocol extends Component
Thread Safety
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 will get 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.
Remarks
The properties of the WebClientProtocol class are used to control the behavior of the transport used to transmit the XML Web service request and response. The properties on this class map to properties found on WebRequest. Instances of classes deriving from WebRequest, such as HttpWebRequest, are used as the transport mechanism for XML Web services created using ASP.NET.To communicate with an XML Web service, you must create a proxy class deriving indirectly or directly from WebClientProtocol for the XML Web service you want to call. 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 WebClientProtocol is the base class for your client proxy, you will find its properties on your proxy classes. These properties are useful for controlling the request behavior of the underlying transport. For instance, use the Credentials property for calling authenticated XML Web services. Many of the WebClientProtocol properties are used to initialize the WebRequest object that is used to make the Web request.
Example
[Visual Basic, C#, JScript] 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 sets proxy information and client credentials on the proxy class prior to calling the remote XML Web service method.
[Visual Basic]
<%@ 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()
' Set the client-side credentials using the Credentials property.
Dim credentials As New NetworkCredential("Joe", "password", "mydomain")
math.Credentials = credentials
' Do not allow the server to redirect the request.
math.AllowAutoRedirect = False
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>
[C#]
<%@ 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();
// Set the client-side credentials using the Credentials property.
ICredentials credentials = new NetworkCredential("Joe","mydomain","password");
math.Credentials = credentials;
// Do not allow the server to redirect the request.
math.AllowAutoRedirect = false;
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>
[JScript]
<%@ Page Language="JSCRIPT" src="source.js" %>
<%@ Import Namespace="System.Net" %>
<html>
<script language="JSCRIPT" runat="server">
function EnterBtn_Click(src : Object, e : EventArgs){
var math : MyMath.Math = new MyMath.Math()
// Set the client-side credentials using the Credentials property.
var credentials : NetworkCredential = new NetworkCredential("Joe", "password", "mydomain")
math.Credentials = credentials
// Do not allow the server to redirect the request.
math.AllowAutoRedirect = false
var iTotal : int = math.Add(Convert.ToInt32(Num1.Text), Convert.ToInt32(Num2.Text))
Total.Text = "Total: " + iTotal.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>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.Services.Protocols
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: System.Web.Services (in System.Web.Services.dll)
See Also
WebClientProtocol Members | System.Web.Services.Protocols Namespace | SoapHttpClientProtocol | HttpWebRequest