The Encoding used to make the client request to the XML Web service.
[Visual Basic] Public Property RequestEncoding As Encoding [C#] public Encoding RequestEncoding {get; set;} [C++] public: __property Encoding* get_RequestEncoding(); public: __property void set_RequestEncoding(Encoding*); [JScript] public function get RequestEncoding() : Encoding; public function set RequestEncoding(Encoding);
The character encoding for the client request. The default is a null reference (Nothing in Visual Basic), which uses the default encoding for the underlying transport and protocol.
The RequestEncoding determines the encoding for the request message. The ContentType of the request will be annotated with the encoding value.
Classes deriving from WebClientProtocol support a particular protocol, such as SoapHttpClientProtocol does for SOAP, set this property to conform to encoding requirements for the specific protocol. For example, the SoapHttpClientProtocol sets the default encoding to UTF-8.
[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 explicitly sets RequestEncoding to UTF-8.
[Visual Basic] <html> <script language="VB" runat="server"> Sub EnterBtn_Click(Src As Object, E As EventArgs) Dim math As New MyMath.Math() ' Set the Content Type to UTF-8. math.RequestEncoding = System.Text.Encoding.UTF8 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#] <html> <script language="C#" runat="server"> void EnterBtn_Click(Object Src, EventArgs E) { MyMath.Math math = new MyMath.Math(); // Set the Content Type to UTF-8. math.RequestEncoding = System.Text.Encoding.UTF8; 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] <html> <script language="JSCRIPT" runat="server"> function EnterBtn_Click(src : Object, e : EventArgs){ var math : MyMath.Math = new MyMath.Math() // Set the Content Type to UTF-8. math.RequestEncoding = System.Text.Encoding.UTF8 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.
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
WebClientProtocol Class | WebClientProtocol Members | System.Web.Services.Protocols Namespace | Encoding | ContentType | WebRequest