Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HttpSimpleClientProtocol Class

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

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

<ComVisibleAttribute(True)> _
Public MustInherit Class HttpSimpleClientProtocol
	Inherits HttpWebClientProtocol
Dim instance As HttpSimpleClientProtocol

/** @attribute ComVisibleAttribute(true) */ 
public abstract class HttpSimpleClientProtocol extends HttpWebClientProtocol
public abstract class HttpSimpleClientProtocol extends HttpWebClientProtocol
Not applicable.

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.

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.

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()
        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

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

public class MyMath extends System.Web.Services.Protocols.HttpGetClientProtocol
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
    public MyMath()
    } //MyMath
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
    /** @attribute System.Web.Services.Protocols.HttpMethodAttribute
    public int Add(String num1, String num2)
        return Integer.parseInt(System.Convert.ToString( 
            this.Invoke("Add", this.get_Url() + "/Add", 
            new Object[]{num1, num2})));
    } //Add  
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
    public System.IAsyncResult BeginAdd(String num1, String num2, 
        System.AsyncCallback callback, Object asyncState)
        return this.BeginInvoke("Add", this.get_Url() + "/Add", 
			new Object[]{num1, num2}, callback, asyncState) ;
    } //BeginAdd   
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
    public int EndAdd(System.IAsyncResult asyncResult)
        return Integer.parseInt(System.Convert.ToString(
            this.EndInvoke(asyncResult))) ;
    } //EndAdd
} //MyMath

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

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

This type is thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, 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

Community Additions

© 2015 Microsoft