WebClientProtocol.RequestEncoding プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Encoding XML Web サービスに対するクライアント要求を行うために使用されます。
public:
property System::Text::Encoding ^ RequestEncoding { System::Text::Encoding ^ get(); void set(System::Text::Encoding ^ value); };
public System.Text.Encoding RequestEncoding { get; set; }
[System.ComponentModel.SettingsBindable(true)]
public System.Text.Encoding RequestEncoding { get; set; }
member this.RequestEncoding : System.Text.Encoding with get, set
[<System.ComponentModel.SettingsBindable(true)>]
member this.RequestEncoding : System.Text.Encoding with get, set
Public Property RequestEncoding As Encoding
プロパティ値
クライアント要求の文字エンコード。 既定値は null で、基になるトランスポートとプロトコルの既定のエンコードが使用されます。
- 属性
例
次の例は、 Math という名前の XML Web サービスを呼び出す ASP.NET Web フォームです。
EnterBtn_Click関数内で、Web フォームは RequestEncoding を UTF-8 に明示的に設定します。
Important
この例には、潜在的なセキュリティ上の脅威であるユーザー入力を受け入れるテキスト ボックスがあります。 既定では、ASP.NET Web ページでは、ユーザー入力にスクリプトや 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="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>
注釈
RequestEncodingは、要求メッセージのエンコードを決定します。 要求の ContentType にはエンコード値で注釈が付けられます。
WebClientProtocolから派生したクラスは、SOAP 用のSoapHttpClientProtocolなど、特定のプロトコルをサポートします。このプロパティは、特定のプロトコルのエンコード要件に準拠するように設定します。 たとえば、 SoapHttpClientProtocol は既定のエンコードを UTF-8 に設定します。