Export (0) Print
Expand All

HttpGetClientProtocol Class

The base class for XML Web service client proxies that use the HTTP-GET protocol.

For a list of all members of this type, see HttpGetClientProtocol 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

[Visual Basic]
Public Class HttpGetClientProtocol
   Inherits HttpSimpleClientProtocol
[C#]
public class HttpGetClientProtocol : HttpSimpleClientProtocol
[C++]
public __gc class HttpGetClientProtocol : public
   HttpSimpleClientProtocol
[JScript]
public class HttpGetClientProtocol extends HttpSimpleClientProtocol

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

When an XML Web service client uses the HTTP-GET protocol, parameters are encoded within the URL and the response is returned in plain XML.

If you are building an XML Web service client using ASP.NET, then a proxy class deriving indirectly or directly from WebClientProtocol needs to be created for the XML Web service you want to call. When the XML Web service client calls the XML Web service using HTTP, derive the proxy class from HttpSimpleClientProtocol, which in turn derives from WebClientProtocol.

HttpGetClientProtocol and HttpPostClientProtocol derive from HttpSimpleClientProtocol, providing the support for calling an XML Web service method using the HTTP-GET and HTTP-POST protocols respectively. Clients calling an XML Web service using SOAP should derive from SoapHttpClientProtocol.

For details on building a proxy class, see Creating an XML Web Service Proxy.

Example

[Visual Basic, C#, C++] The following 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.

[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));
    }
};

[Visual Basic, C#, C++] The following example is the Math XML Web service, from which the above proxy class was created.

[Visual Basic] 
<%@ WebService Language="VB" Class="Math"%>
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 'Add
End Class 'Math

[C#] 
<%@ WebService Language="C#" Class="Math"%>
 using System.Web.Services;
 using System;
 
 public class Math {
      [ 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 Language Filter 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

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

HttpGetClientProtocol Members | System.Web.Services.Protocols Namespace | HttpSimpleClientProtocol | WebClientProtocol | HttpPostClientProtocol | SoapHttpClientProtocol

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft