HttpSimpleClientProtocol HttpSimpleClientProtocol HttpSimpleClientProtocol HttpSimpleClientProtocol Class

Definition

Represents the base class for communicating with an XML Web service using the simple HTTP-GET and HTTP-POST protocols bindings.

public ref class HttpSimpleClientProtocol abstract : System::Web::Services::Protocols::HttpWebClientProtocol
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class HttpSimpleClientProtocol : System.Web.Services.Protocols.HttpWebClientProtocol
type HttpSimpleClientProtocol = class
    inherit HttpWebClientProtocol
Public MustInherit Class HttpSimpleClientProtocol
Inherits HttpWebClientProtocol
Inheritance
Derived
Attributes

Examples

The following code example is a proxy class generated by Wsdl.exe for the Math XML Web service below. The proxy class derives from HttpGetClientProtocol, 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::HttpGetClientProtocol
{
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::UrlParameterWriter::typeid)]
   [returnvalue:System::Xml::Serialization::XmlRootAttribute("snippet1>",Namespace="http://www.contoso.com/",IsNullable=false)]
   int Add( String^ num1, String^ num2 )
   {
      array<Object^>^temp0 = {num1,num2};
      return  *dynamic_cast<int^>(this->Invoke( "Add", (String::Concat( this->Url, "/Add" )), temp0 ));
   }

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

   [System::Diagnostics::DebuggerStepThroughAttribute]
   int EndAdd( System::IAsyncResult^ asyncResult )
   {
      return  *dynamic_cast<int^>(this->EndInvoke( asyncResult ));
   }
};
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)));
    }
}
Option Strict On
Option Explicit On

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

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

#using <System.EnterpriseServices.dll>
#using <System.Web.Services.dll>

using namespace System::Web::Services;
using namespace System;
public ref class Math
{
public:

   [WebMethod]
   int Add( int num1, int num2 )
   {
      return num1 + num2;
   }

};

using System.Web.Services;
using System;
 
public class Math
{
    [WebMethod]
    public int Add(int num1, int num2)
    {
        return num1 + num2;
    }
}
Imports System.Web.Services

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

Remarks

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

The Web Services Description Language tool (Wsdl.exe) generates derived classes of HttpSimpleClientProtocol for a given Service Description.

Constructors

HttpSimpleClientProtocol() HttpSimpleClientProtocol() HttpSimpleClientProtocol() HttpSimpleClientProtocol()

Initializes a new instance of the HttpSimpleClientProtocol class.

Methods

Abort() Abort() Abort() Abort()

Cancels a request to an XML Web service method.

(Inherited from WebClientProtocol)
BeginInvoke(String, String, Object[], AsyncCallback, Object) BeginInvoke(String, String, Object[], AsyncCallback, Object) BeginInvoke(String, String, Object[], AsyncCallback, Object) BeginInvoke(String, String, Object[], AsyncCallback, Object)

Starts an asynchronous invocation of a method of an XML Web service.

CancelAsync(Object) CancelAsync(Object) CancelAsync(Object) CancelAsync(Object)

Cancels an asynchronous call to an XML Web service method, unless the call has already completed.

(Inherited from HttpWebClientProtocol)
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
EndInvoke(IAsyncResult) EndInvoke(IAsyncResult) EndInvoke(IAsyncResult) EndInvoke(IAsyncResult)

Completes asynchronous invocation of an XML Web service method using HTTP.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetWebRequest(Uri) GetWebRequest(Uri) GetWebRequest(Uri) GetWebRequest(Uri)

Creates a WebRequest for the specified URI.

(Inherited from HttpWebClientProtocol)
GetWebResponse(WebRequest) GetWebResponse(WebRequest) GetWebResponse(WebRequest) GetWebResponse(WebRequest)

Returns a response from a synchronous request to an XML Web service method.

(Inherited from HttpWebClientProtocol)
GetWebResponse(WebRequest, IAsyncResult) GetWebResponse(WebRequest, IAsyncResult) GetWebResponse(WebRequest, IAsyncResult) GetWebResponse(WebRequest, IAsyncResult)

Returns a response from an asynchronous request to an XML Web service method.

(Inherited from HttpWebClientProtocol)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Invoke(String, String, Object[]) Invoke(String, String, Object[]) Invoke(String, String, Object[]) Invoke(String, String, Object[])

Invokes an XML Web service method using HTTP.

InvokeAsync(String, String, Object[], SendOrPostCallback) InvokeAsync(String, String, Object[], SendOrPostCallback) InvokeAsync(String, String, Object[], SendOrPostCallback) InvokeAsync(String, String, Object[], SendOrPostCallback)

Invokes the specified method asynchronously.

InvokeAsync(String, String, Object[], SendOrPostCallback, Object) InvokeAsync(String, String, Object[], SendOrPostCallback, Object) InvokeAsync(String, String, Object[], SendOrPostCallback, Object) InvokeAsync(String, String, Object[], SendOrPostCallback, Object)

Invokes the specified method asynchronously while maintaining an associated state.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)

Properties

AllowAutoRedirect AllowAutoRedirect AllowAutoRedirect AllowAutoRedirect

Gets or sets whether the client automatically follows server redirects.

(Inherited from HttpWebClientProtocol)
CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
ClientCertificates ClientCertificates ClientCertificates ClientCertificates

Gets the collection of client certificates.

(Inherited from HttpWebClientProtocol)
ConnectionGroupName ConnectionGroupName ConnectionGroupName ConnectionGroupName

Gets or sets the name of the connection group for the request.

(Inherited from WebClientProtocol)
Container Container Container Container

Gets the IContainer that contains the Component.

(Inherited from Component)
CookieContainer CookieContainer CookieContainer CookieContainer

Gets or sets the collection of cookies.

(Inherited from HttpWebClientProtocol)
Credentials Credentials Credentials Credentials

Gets or sets security credentials for XML Web service client authentication.

(Inherited from WebClientProtocol)
DesignMode DesignMode DesignMode DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
EnableDecompression EnableDecompression EnableDecompression EnableDecompression

Gets or sets a value that indicates whether decompression is enabled for this HttpWebClientProtocol.

(Inherited from HttpWebClientProtocol)
Events Events Events Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
PreAuthenticate PreAuthenticate PreAuthenticate PreAuthenticate

Gets or sets whether pre-authentication is enabled.

(Inherited from WebClientProtocol)
Proxy Proxy Proxy Proxy

Gets or sets proxy information for making an XML Web service request through a firewall.

(Inherited from HttpWebClientProtocol)
RequestEncoding RequestEncoding RequestEncoding RequestEncoding

The Encoding used to make the client request to the XML Web service.

(Inherited from WebClientProtocol)
Site Site Site Site

Gets or sets the ISite of the Component.

(Inherited from Component)
Timeout Timeout Timeout Timeout

Indicates the time an XML Web service client waits for the reply to a synchronous XML Web service request to arrive (in milliseconds).

(Inherited from WebClientProtocol)
UnsafeAuthenticatedConnectionSharing UnsafeAuthenticatedConnectionSharing UnsafeAuthenticatedConnectionSharing UnsafeAuthenticatedConnectionSharing

Gets or sets a value that indicates whether connection sharing is enabled when the client uses NTLM authentication to connect to the Web server that hosts the XML Web service.

(Inherited from HttpWebClientProtocol)
Url Url Url Url

Gets or sets the base URL of the XML Web service the client is requesting.

(Inherited from WebClientProtocol)
UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials

Gets or sets a value that indicates whether to set the Credentials property to the value of the DefaultCredentials property.

(Inherited from WebClientProtocol)
UserAgent UserAgent UserAgent UserAgent

Gets or sets the value for the user agent header that is sent with each request.

(Inherited from HttpWebClientProtocol)

Events

Disposed Disposed Disposed Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Applies to

Thread Safety

This type is thread safe.

See also