Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

SoapHttpClientProtocol Class

Specifies the class client that proxies derive from when using SOAP.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)
[ComVisibleAttribute(true)] 
public ref class SoapHttpClientProtocol : public HttpWebClientProtocol
/** @attribute ComVisibleAttribute(true) */ 
public class SoapHttpClientProtocol extends HttpWebClientProtocol
ComVisibleAttribute(true) 
public class SoapHttpClientProtocol extends HttpWebClientProtocol
Not applicable.

If you are building an XML Web service client, then a proxy class that derives indirectly or directly from WebClientProtocol must be created for the XML Web service. When the XML Web service client calls 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, create a proxy class that derives indirectly or directly from WebClientProtocol for the XML Web service you want to call. Instead of creating the proxy class manually, use the Web Services Description Language tool (Wsdl.exe) 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 the Invoke method, whereas asynchronous calls are made using the BeginInvoke method and the EndInvoke method.

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 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 the BeginInvoke method and the EndInvoke method. If the introduced methods are synchronous, call the Invoke method. The overridden constructor typically sets the Url property to the URL of the XML Web service method.

The following code example is a proxy class generated by Wsdl.exe for the Math XML Web service. The proxy class derives from SoapHttpClientProtocol, which derives from the abstract WebClientProtocol 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;

namespace MyMath
{

   [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="http://www.contoso.com/")]
   public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol
   {
   public:

      [System::Diagnostics::DebuggerStepThroughAttribute]
      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)]
      int Add( int num1, int num2 )
      {
         array<Object^>^temp0 = {num1,num2};
         array<Object^>^results = this->Invoke( "Add", temp0 );
         return  *dynamic_cast<int^>(results[ 0 ]);
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState )
      {
         array<Object^>^temp1 = {num1,num2};
         return this->BeginInvoke( "Add", temp1, callback, asyncState );
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      int EndAdd( System::IAsyncResult^ asyncResult )
      {
         array<Object^>^results = this->EndInvoke( asyncResult );
         return  *dynamic_cast<int^>(results[ 0 ]);
      }

   };

}


package MyMath; 

import System.Diagnostics.*;
import System.Xml.Serialization.*;
import System.*;
import System.Web.Services.Protocols.*;
import System.Web.Services.*;

/** @attribute System.Web.Services.WebServiceBindingAttribute(
    Name = "MyMathSoap", Namespace = "http://www.contoso.com/")
 */

public class MyMath extends System.Web.Services.Protocols.SoapHttpClientProtocol
{
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    public MyMath()
    {
        this.set_Url("http://www.contoso.com/math.asmx");
    } //MyMath

    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */
    /** @attribute 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[] { (Int32)num1, (Int32)num2 });
        return (int)((Int32)results.get_Item(0));
    } //Add

    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    public System.IAsyncResult BeginAdd(int num1, int num2, 
        System.AsyncCallback callback, Object asyncState)
    {
        return this.BeginInvoke("Add", 
            new Object[] { (Int32)num1, (Int32)num2 }, callback, asyncState);
    } //BeginAdd

    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    public int EndAdd(System.IAsyncResult asyncResult)
    {
        Object results[] = this.EndInvoke(asyncResult);
        return (int)((Int32)results.get_Item(0));
    } //EndAdd
} //MyMath

The following code example is the Math XML Web service, from which the preceding proxy class was generated.

Security noteSecurity Note:

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio).

No code example is currently available or this language may not be supported.
<%@ WebService Language="VJ#" Class="MyMath"%>
import System.Web.Services .* ;
import System .* ;

/** @attribute WebService(Namespace = "http://www.contoso.com/")
* */
public class MyMath
{
   /** @attribute WebMethod()
   * */
   public int Add(int num1, int num2) 
   {
      return num1 + num2 ;
   } 
} 

This type is thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.