次の方法で共有


HttpPostClientProtocol クラス

HTTP-POST プロトコルを使用する XML Web サービス クライアント プロキシの基本クラス。

この型のすべてのメンバの一覧については、HttpPostClientProtocol メンバ を参照してください。

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Web.Services.Protocols.WebClientProtocol
            System.Web.Services.Protocols.HttpWebClientProtocol
               System.Web.Services.Protocols.HttpSimpleClientProtocol
                  System.Web.Services.Protocols.HttpPostClientProtocol

Public Class HttpPostClientProtocol
   Inherits HttpSimpleClientProtocol
[C#]
public class HttpPostClientProtocol : HttpSimpleClientProtocol
[C++]
public __gc class HttpPostClientProtocol : public
   HttpSimpleClientProtocol
[JScript]
public class HttpPostClientProtocol extends
   HttpSimpleClientProtocol

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

XML Web サービス クライアントが HTTP-POST プロトコルを使用している場合、既定ではパラメータは HTTP 内でエンコードされ、応答は書式なし XML で返されます。このプロトコルは、 MimeFormatter から派生したクラスを使用して、パラメータと戻り値を標準の MIME 形式にエンコードします。使用するエンコーダは、サービスの説明で指定します。

ASP.NET を使用して XML Web サービス クライアントを構築する場合は、呼び出す XML Web サービスで使用する WebClientProtocol から間接または直接に派生するプロキシ クラスを作成する必要があります。XML Web サービス クライアントが HTTP を使用して呼び出すと、 WebClientProtocol から順番に派生される HttpSimpleClientProtocol からプロキシ クラスが派生されます。

HttpGetClientProtocol および HttpPostClientProtocolHttpSimpleClientProtocol から派生し、それぞれ HTTP-GET および HTTP-POST を使用して XML Web サービス メソッドの呼び出しをサポートします。SOAP を使用して XML Web サービスを呼び出しているクライアントは、 SoapHttpClientProtocol から派生する必要があります。プロキシ クラス構築の詳細については、「 XML Web サービス プロキシの作成 」を参照してください。

使用例

[Visual Basic, C#, C++] Wsdl.exe ユーティリティによって、下の Math XML Web サービス用に生成されるプロキシ クラスの例を次に示します。プロキシ クラスは、 HttpPostClientProtocol から派生します。このクラスは、 HttpSimpleClientProtocol 抽象クラスから派生します。

 
Option Strict On
Option Explicit On

Imports System
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

Public Class MyMath
    Inherits System.Web.Services.Protocols.HttpPostClientProtocol
    
    <System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Public Sub New()
        MyBase.New
        Me.Url = "https://www.contoso.com/math.asmx"
    End Sub
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.Web.Services.Protocols.HttpMethodAttribute(GetType(System.Web.Services.Protocols.XmlReturnReader), GetType(System.Web.Services.Protocols.HtmlFormParameterWriter))>  _
    Public Function Add(ByVal num1 As String, ByVal num2 As String) As <System.Xml.Serialization.XmlRootAttribute("int", [Namespace]:="https://www.contoso.com/", IsNullable:=false)> Integer
        Return CType(Me.Invoke("Add", (Me.Url + "/Add"), New Object() {num1, num2}),Integer)
    End Function
    
    <System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Public Function BeginAdd(ByVal num1 As String, ByVal num2 As String, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
        Return Me.BeginInvoke("Add", (Me.Url + "/Add"), New Object() {num1, num2}, callback, asyncState)
    End Function
    
    <System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Public Function EndAdd(ByVal asyncResult As System.IAsyncResult) As Integer
        Return CType(Me.EndInvoke(asyncResult),Integer)
    End Function
End Class

[C#] 
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.Web.Services;


public class MyMath : System.Web.Services.Protocols.HttpPostClientProtocol {
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    public MyMath() {
        this.Url = "https://www.contoso.com/math.asmx";
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Web.Services.Protocols.HttpMethodAttribute(typeof(System.Web.Services.Protocols.XmlReturnReader), typeof(System.Web.Services.Protocols.HtmlFormParameterWriter))]
    [return: System.Xml.Serialization.XmlRootAttribute("int", Namespace="https://www.contoso.com/", IsNullable=false)]
    public int Add(string num1, string num2) {
        return ((int)(this.Invoke("Add", (this.Url + "/Add"), new object[] {num1,
                    num2})));
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    public System.IAsyncResult BeginAdd(string num1, string num2, System.AsyncCallback callback, object asyncState) {
        return this.BeginInvoke("Add", (this.Url + "/Add"), new object[] {num1,
                    num2}, callback, asyncState);
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    public int EndAdd(System.IAsyncResult asyncResult) {
        return ((int)(this.EndInvoke(asyncResult)));
    }
}

[C++] 
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
#using <System.dll>
using namespace System::Diagnostics;
using namespace System::Xml::Serialization;
using namespace System;
using namespace System::Web::Services::Protocols;
using namespace System::Web::Services;


public __gc class MyMath : public System::Web::Services::Protocols::HttpPostClientProtocol {
    
public:
    [System::Diagnostics::DebuggerStepThroughAttribute]
    MyMath() {
        this->Url = S"https://www.contoso.com/math.asmx";
    }
    
    [System::Diagnostics::DebuggerStepThroughAttribute]
    [System::Web::Services::Protocols::HttpMethodAttribute(__typeof(System::Web::Services::Protocols::XmlReturnReader),
        __typeof(System::Web::Services::Protocols::HtmlFormParameterWriter))]
    [returnvalue: System::Xml::Serialization::XmlRootAttribute(S"int", Namespace=S"https://www.contoso.com/", IsNullable=false)]
    int Add(String* num1, String* num2) {
        Object* temp2 [] = {num1, num2};
        return *dynamic_cast<__box int*>(this->Invoke(S"Add", (String::Concat( this->Url, S"/Add" )), temp2));
    }
    
    [System::Diagnostics::DebuggerStepThroughAttribute]
    System::IAsyncResult* BeginAdd(String* num1, String* num2, System::AsyncCallback* callback, Object* asyncState) {
        Object* temp3 [] = {num1, num2};
        return this->BeginInvoke(S"Add", (String::Concat( this->Url, S"/Add" )), temp3, callback, asyncState);
    }
    
    [System::Diagnostics::DebuggerStepThroughAttribute]
    int EndAdd(System::IAsyncResult* asyncResult) {
        return *dynamic_cast<__box int*>(this->EndInvoke(asyncResult));
    }
};

[Visual Basic, C#, C++] 前のプロキシ クラスの作成元の Math XML Web サービスの例を次に示します。

 
<%@ WebService Language="VB" Class="Math"%>
Imports System.Web.Services
Imports System

Public Class Math
    <WebMethod()> _
    Public Function Add(num1 As Integer, num2 As Integer) As Integer
        Return num1 + num2
    End Function 'Add
End Class 'Math

[C#] 
<%@ WebService Language="C#" Class="Math"%>
 using System.Web.Services;
 using System;
 
 public class Math {
      [ WebMethod ]
      public int Add(int num1, int num2) {
          return num1+num2;
          }
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Web.Services.Protocols

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Web.Services (System.Web.Services.dll 内)

参照

HttpPostClientProtocol メンバ | System.Web.Services.Protocols 名前空間 | HttpGetClientProtocol | HttpSimpleClientProtocol | WebClientProtocol | SoapHttpClientProtocol