Freigeben über


WebClientProtocol.RequestEncoding-Eigenschaft

Die Encoding, die für die Clientanforderung an den XML-Webdienst verwendet wird.

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

Syntax

'Declaration
Public Property RequestEncoding As Encoding
'Usage
Dim instance As WebClientProtocol
Dim value As Encoding

value = instance.RequestEncoding

instance.RequestEncoding = value
public Encoding RequestEncoding { get; set; }
public:
property Encoding^ RequestEncoding {
    Encoding^ get ();
    void set (Encoding^ value);
}
/** @property */
public Encoding get_RequestEncoding ()

/** @property */
public void set_RequestEncoding (Encoding value)
public function get RequestEncoding () : Encoding

public function set RequestEncoding (value : Encoding)

Eigenschaftenwert

Die Zeichencodierung für die Clientanforderung. Der Standardwert lautet NULL (Nothing in Visual Basic), wobei die Standardcodierung für den zugrunde liegenden Transport und das zugrunde liegende Protokoll verwendet wird.

Hinweise

RequestEncoding bestimmt die Codierung für die Anforderungsmeldung. Der ContentType der Anforderung wird mit dem Codierungswert ergänzt.

Klassen, die von WebClientProtocol abgeleitet sind, unterstützen ein bestimmtes Protokoll, z. B. unterstützt SoapHttpClientProtocol SOAP. Legen Sie diese Eigenschaft fest, sodass den Codierungsanforderungen für das jeweilige Protokoll entsprochen wird. Das SoapHttpClientProtocol legt die Standardcodierung beispielsweise auf UTF-8 fest.

Beispiel

Das folgende Beispiel ist eine ASP.NET-Web Form, die einen XML-Webdienst mit dem Namen Math aufruft. In der EnterBtn_Click-Funktion legt die Web Form RequestEncoding explizit auf UTF-8 fest.

<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>
   
<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>
   
<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>
   

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

WebClientProtocol-Klasse
WebClientProtocol-Member
System.Web.Services.Protocols-Namespace
Encoding
ContentType
WebRequest