HttpPostClientProtocol Class
The base class for XML Web service client proxies that use the HTTP-POST protocol.
Assembly: System.Web.Services (in System.Web.Services.dll)
When an XML Web service client uses the HTTP-POST protocol, by default parameters are encoded within the HTTP body using URL encoding rules and uses plain XML for the response. This protocol uses classes that derive from MimeFormatter to encode parameters and return values into standard MIME formats. The encoders to use are specified in the service description.
If you are building an XML Web service client using ASP.NET, then a proxy class deriving indirectly or directly from WebClientProtocol needs to be created for the XML Web service you want to call. When the XML Web service client is calling using HTTP, derive the proxy class HttpSimpleClientProtocol, which in turn derives from WebClientProtocol.
HttpGetClientProtocol and HttpPostClientProtocol derive from HttpSimpleClientProtocol, providing the support for calling an XML Web service method using HTTP-GET and HTTP-POST respectively. Clients calling an XML Web service using SOAP should derive from SoapHttpClientProtocol.
For details on building a proxy class, see [<topic://cpconcreatingwebserviceproxy>].
The following example is a proxy class generated by the Wsdl.exe utility for the Math XML Web service below. The proxy class derives from HttpPostClientProtocol, which derives from the abstract HttpSimpleClientProtocol class.
#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 ref class MyMath: public System::Web::Services::Protocols::HttpPostClientProtocol { public: [System::Diagnostics::DebuggerStepThroughAttribute] MyMath() { this->Url = "http://www.contoso.com/math.asmx"; } [System::Diagnostics::DebuggerStepThroughAttribute] [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid, System::Web::Services::Protocols::HtmlFormParameterWriter::typeid)] [returnvalue:System::Xml::Serialization::XmlRootAttribute("snippet1>",Namespace="http://www.contoso.com/",IsNullable=false)] int Add( String^ num1, String^ num2 ) { array<Object^>^temp2 = {num1,num2}; return *dynamic_cast<int^>(this->Invoke( "Add", (String::Concat( this->Url, "/Add" )), temp2 )); } [System::Diagnostics::DebuggerStepThroughAttribute] System::IAsyncResult^ BeginAdd( String^ num1, String^ num2, System::AsyncCallback^ callback, Object^ asyncState ) { array<Object^>^temp3 = {num1,num2}; return this->BeginInvoke( "Add", (this->Url + "/Add" ), temp3, callback, asyncState ); } [System::Diagnostics::DebuggerStepThroughAttribute] int EndAdd( System::IAsyncResult^ asyncResult ) { return *dynamic_cast<int^>(this->EndInvoke( asyncResult )); } };
#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"http://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"http://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));
}
};
The following example is the Math XML Web service, from which the previous proxy class was created.
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
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.