SoapHttpClientProtocol Class
Specifies the class client proxies derive from when using SOAP.
For a list of all members of this type, see SoapHttpClientProtocol Members.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Web.Services.Protocols.WebClientProtocol
System.Web.Services.Protocols.HttpWebClientProtocol
System.Web.Services.Protocols.SoapHttpClientProtocol
[Visual Basic] Public Class SoapHttpClientProtocol Inherits HttpWebClientProtocol [C#] public class SoapHttpClientProtocol : HttpWebClientProtocol [C++] public __gc class SoapHttpClientProtocol : public HttpWebClientProtocol [JScript] public class SoapHttpClientProtocol extends HttpWebClientProtocol
Thread Safety
This type is safe for multithreaded operations.
Remarks
If you are building an XML Web service client, then a proxy class deriving indirectly or directly from WebClientProtocol needs to be created for the XML Web service. When the XML Web service client is calling using SOAP, the proxy class must derive from SoapHttpClientProtocol, which derives from HttpWebClientProtocol. HttpWebClientProtocol in turn derives from WebClientProtocol
To communicate with an XML Web service, you must create a proxy class deriving indirectly or directly from WebClientProtocol for the XML Web service you want to call. Instead of creating the proxy class manually, you can use the Wsdl.exe tool to create a proxy class for a given XML Web service's service description. When a proxy class is generated for the SOAP protocol, synchronous calls to XML Web service methods are made via Invoke, whereas asynchronous calls are made via BeginInvoke and EndInvoke.
Notes to Inheritors: When you override this class, you can introduce methods in the derived class which are specific to a particular type of XML Web service. The methods simply capture the parameters, and call the base class to do the work of communicating with the XML Web service. 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 Url of the XML Web service method.
Example
[Visual Basic, C#, C++] 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 SoapHttpClientProtocol, which derives from the abstract WebClientProtocol 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 Namespace MyMath <System.Web.Services.WebServiceBindingAttribute(Name:="MyMathSoap", [Namespace]:="http://www.contoso.com/")> _ Public Class MyMath Inherits System.Web.Services.Protocols.SoapHttpClientProtocol <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.SoapDocumentMethodAttribute("http://www.contoso.com/Add", RequestNamespace:="http://www.contoso.com/", ResponseNamespace:="http://www.contoso.com/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _ Public Function Add(ByVal num1 As Integer, ByVal num2 As Integer) As Integer Dim results() As Object = Me.Invoke("Add", New Object() {num1, num2}) Return CType(results(0),Integer) End Function <System.Diagnostics.DebuggerStepThroughAttribute()> _ Public Function BeginAdd(ByVal num1 As Integer, ByVal num2 As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult Return Me.BeginInvoke("Add", New Object() {num1, num2}, callback, asyncState) End Function <System.Diagnostics.DebuggerStepThroughAttribute()> _ Public Function EndAdd(ByVal asyncResult As System.IAsyncResult) As Integer Dim results() As Object = Me.EndInvoke(asyncResult) Return CType(results(0),Integer) End Function End Class End Namespace [C#] namespace MyMath { using System.Diagnostics; using System.Xml.Serialization; using System; using System.Web.Services.Protocols; using System.Web.Services; [System.Web.Services.WebServiceBindingAttribute(Name="MyMathSoap", Namespace="http://www.contoso.com/")] public class MyMath : System.Web.Services.Protocols.SoapHttpClientProtocol { [System.Diagnostics.DebuggerStepThroughAttribute()] public MyMath() { this.Url = "http://www.contoso.com/math.asmx"; } [System.Diagnostics.DebuggerStepThroughAttribute()] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.contoso.com/Add", RequestNamespace="http://www.contoso.com/", ResponseNamespace="http://www.contoso.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public int Add(int num1, int num2) { object[] results = this.Invoke("Add", new object[] {num1, num2}); return ((int)(results[0])); } [System.Diagnostics.DebuggerStepThroughAttribute()] public System.IAsyncResult BeginAdd(int num1, int num2, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("Add", new object[] {num1, num2}, callback, asyncState); } [System.Diagnostics.DebuggerStepThroughAttribute()] public int EndAdd(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); return ((int)(results[0])); } } } [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; namespace MyMath { [System::Web::Services::WebServiceBindingAttribute(Name=S"MyMathSoap", Namespace=S"http://www.contoso.com/")] public __gc class MyMath : public System::Web::Services::Protocols::SoapHttpClientProtocol { public: [System::Diagnostics::DebuggerStepThroughAttribute] MyMath() { this->Url = S"http://www.contoso.com/math.asmx"; } [System::Diagnostics::DebuggerStepThroughAttribute] [System::Web::Services::Protocols::SoapDocumentMethodAttribute(S"http://www.contoso.com/Add", RequestNamespace=S"http://www.contoso.com/", ResponseNamespace=S"http://www.contoso.com/", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] int Add(int num1, int num2) { Object* temp0 [] = {__box(num1), __box(num2)}; Object* results[] = this->Invoke(S"Add", temp0); return *dynamic_cast<__box int*>(results[0]); } [System::Diagnostics::DebuggerStepThroughAttribute] System::IAsyncResult* BeginAdd(int num1, int num2, System::AsyncCallback* callback, Object* asyncState) { Object* temp1 [] = {__box(num1), __box(num2)}; return this->BeginInvoke(S"Add", temp1, callback, asyncState); } [System::Diagnostics::DebuggerStepThroughAttribute] int EndAdd(System::IAsyncResult* asyncResult) { Object* results[] = this->EndInvoke(asyncResult); return *dynamic_cast<__box int*>(results[0]); } }; }
The following example is the Math XML Web service, from which the above proxy class was generated.
[Visual Basic] <%@ WebService Language="VB" Class="MyMath"%> Imports System.Web.Services Imports System <WebService(Namespace:="http://www.contoso.com/")> _ Public Class MyMath <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="MyMath"%> using System.Web.Services; using System; [WebService(Namespace="http://www.contoso.com/")] public class MyMath { [ WebMethod ] public int Add(int num1, int num2) { return num1+num2; } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
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, .NET Compact Framework
Assembly: System.Web.Services (in System.Web.Services.dll)
See Also
SoapHttpClientProtocol Members | System.Web.Services.Protocols Namespace | HttpSimpleClientProtocol