HttpSimpleClientProtocol Class
The base class for communicating with an XML Web service using the simple HTTP-GET and HTTP-POST protocols bindings.
For a list of all members of this type, see HttpSimpleClientProtocol Members.
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.HttpGetClientProtocol
System.Web.Services.Protocols.HttpPostClientProtocol
[Visual Basic] MustInherit Public Class HttpSimpleClientProtocol Inherits HttpWebClientProtocol [C#] public abstract class HttpSimpleClientProtocol : HttpWebClientProtocol [C++] public __gc __abstract class HttpSimpleClientProtocol : public HttpWebClientProtocol [JScript] public abstract class HttpSimpleClientProtocol extends HttpWebClientProtocol
Thread Safety
This type is safe for multithreaded operations.
Remarks
Specifies most of the implementation for communicating with an XML Web service over HTTP using encoders to encode the parameters and return values into common MIME formats. These encoders derive from the MimeFormatter class. By default, a proxy class deriving from HttpSimpleClientProtocol encodes parameters using the application/x-www-form-urlencoded MIME type and the response in plain XML. Custom mime formatters can be specified using the HttpMethodAttribute attribute, however there is no support for integrating this into a service description and proxy generation.
Notes to Inheritors: When you override this class, you can introduce methods in the derived class which are specific to a particular type of an XML Web service. The methods simply capture the parameters, and call the base class to do the work of communicating with the site. If the introduced methods are asynchronous, call BeginInvoke and EndInvoke. If the introduced methods are synchronous, call Invoke. The overridden constructor typically sets the Url property to the Uri of the XML Web service method.
The Wsdl.exe utility generates derived classes of HttpSimpleClientProtocol for a given Service Description.
Example
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 HttpGetClientProtocol, which derives from the abstract HttpSimpleClientProtocol class.
[Visual Basic] 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.HttpGetClientProtocol <System.Diagnostics.DebuggerStepThroughAttribute()> _ Public Sub New() MyBase.New Me.Url = "http://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.UrlParameterWriter))> _ Public Function Add(ByVal num1 As String, ByVal num2 As String) As <System.Xml.Serialization.XmlRootAttribute("int", [Namespace]:="http://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.HttpGetClientProtocol { [System.Diagnostics.DebuggerStepThroughAttribute()] public MyMath() { this.Url = "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.UrlParameterWriter))] [return: System.Xml.Serialization.XmlRootAttribute("int", Namespace="http://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::HttpGetClientProtocol { 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::UrlParameterWriter))] [returnvalue: System::Xml::Serialization::XmlRootAttribute(S"int", Namespace=S"http://www.contoso.com/", IsNullable=false)] int Add(String* num1, String* num2) { Object* temp0 [] = {num1, num2}; return *dynamic_cast<__box int*>(this->Invoke(S"Add", (String::Concat( this->Url, S"/Add" )), temp0)); } [System::Diagnostics::DebuggerStepThroughAttribute] System::IAsyncResult* BeginAdd(String* num1, String* num2, System::AsyncCallback* callback, Object* asyncState) { Object* temp1 [] = {num1, num2}; return this->BeginInvoke(S"Add", (String::Concat( this->Url, S"/Add" )), temp1, 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 above proxy class was created.
[Visual Basic] 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 End Class [C#] using System.Web.Services; using System; public class Math { [ WebMethod ] public int Add(int num1, int num2) { return num1+num2; } } [C++] #using <mscorlib.dll> #using <System.EnterpriseServices.dll> #using <System.Web.Services.dll> using namespace System::Web::Services; using namespace System; public __gc class Math { public: [ WebMethod ] int Add(int num1, int num2) { return num1+num2; } }; [JScript] import System.Web.Services import System class Math{ public WebMethod() function Add(num1 : int, num2 : int): int{ return num1 + num2 } }
Requirements
Namespace: System.Web.Services.Protocols
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web.Services (in System.Web.Services.dll)
See Also
HttpSimpleClientProtocol Members | System.Web.Services.Protocols Namespace | SoapHttpClientProtocol