Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

HttpGetClientProtocol Class

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

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)
public class HttpGetClientProtocol : HttpSimpleClientProtocol
public class HttpGetClientProtocol extends HttpSimpleClientProtocol
public class HttpGetClientProtocol extends HttpSimpleClientProtocol
Not applicable.

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.

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.

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

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()
    {
        this.set_Url("http://www.contoso.com/math.asmx");
    } //MyMath
   
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */
    /** @attribute System.Web.Services.Protocols.HttpMethodAttribute
        (System.Web.Services.Protocols.XmlReturnReader.class,
        System.Web.Services.Protocols.UrlParameterWriter.class)
     */
    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 example is the Math XML Web service, from which the above proxy class was created.

<%@ 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;
          }
 }

<%@ WebService Language="VJ#" Class="Math"%>

import System.Web.Services.*;
import System.*;

public class Math
{
    /** @attribute WebMethod()
     */
    public int Add(int num1, int num2)
    {
        return num1 + num2 ;
    } //Add
} //Math

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be 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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.