HttpGetClientProtocol 類別

定義

XML Web Service 用戶端 Proxy 的基底類別,使用 HTTP-GET 通訊協定。

public ref class HttpGetClientProtocol : System::Web::Services::Protocols::HttpSimpleClientProtocol
public class HttpGetClientProtocol : System.Web.Services.Protocols.HttpSimpleClientProtocol
type HttpGetClientProtocol = class
    inherit HttpSimpleClientProtocol
Public Class HttpGetClientProtocol
Inherits HttpSimpleClientProtocol
繼承

範例

下列範例是下列 XML Web 服務Wsdl.exe Math 所產生的 Proxy 類別。 Proxy 類別衍生自 HttpGetClientProtocol ,其衍生自抽象 HttpSimpleClientProtocol 類。

#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

下列範例是 Math 建立上述 Proxy 類別的 XML Web 服務。

<%@ 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="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

備註

當 XML Web 服務用戶端使用 HTTP-GET 通訊協定時,參數會在 URL 內編碼,並以純 XML 傳迴響應。

如果您要使用 ASP.NET 建置 XML Web 服務用戶端,則必須針對您要呼叫的 XML Web 服務建立衍生或直接 WebClientProtocol 衍生的 Proxy 類別。 當 XML Web 服務用戶端使用 HTTP 呼叫 XML Web 服務時,請從 HttpSimpleClientProtocol 衍生 Proxy 類別,然後衍生自 WebClientProtocol

HttpGetClientProtocolHttpPostClientProtocol 衍生自 HttpSimpleClientProtocol ,提供分別使用 HTTP-GET 和 HTTP-POST 通訊協定呼叫 XML Web 服務方法的支援。 使用 SOAP 呼叫 XML Web 服務的用戶端應該衍生自 SoapHttpClientProtocol

如需建置 Proxy 類別的詳細資訊,請參閱 建立 XML Web 服務 Proxy

建構函式

HttpGetClientProtocol()

初始化 HttpGetClientProtocol 類別的新執行個體。

屬性

AllowAutoRedirect

取得或設定用戶端是否自動遵循伺服器重新導向。

(繼承來源 HttpWebClientProtocol)
CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
ClientCertificates

取得用戶端憑證的集合。

(繼承來源 HttpWebClientProtocol)
ConnectionGroupName

取得或設定要求的連線群組名稱。

(繼承來源 WebClientProtocol)
Container

取得包含 IContainerComponent

(繼承來源 Component)
CookieContainer

取得或設定 Cookie 的集合。

(繼承來源 HttpWebClientProtocol)
Credentials

取得或設定 XML Web Service 用戶端驗證 (Authentication) 的安全認證。

(繼承來源 WebClientProtocol)
DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
EnableDecompression

取得或設定值,指出是否已啟用這個 HttpWebClientProtocol 的解壓縮。

(繼承來源 HttpWebClientProtocol)
Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
PreAuthenticate

取得或設定是否已啟用預先驗證。

(繼承來源 WebClientProtocol)
Proxy

取得或設定 Proxy 資訊,以製作穿越防火牆的 XML Web Service 要求。

(繼承來源 HttpWebClientProtocol)
RequestEncoding

Encoding,用來建立對 XML Web Service 的用戶端要求。

(繼承來源 WebClientProtocol)
Site

取得或設定 ComponentISite

(繼承來源 Component)
Timeout

表示 XML Web Service 用戶端等待同步 XML Web Service 要求的回覆到達的時間 (單位為毫秒)。

(繼承來源 WebClientProtocol)
UnsafeAuthenticatedConnectionSharing

取得或設定值,指出是否在用戶端使用 NTLM 驗證連接到裝載 XML Web Service 的 Web 伺服器時啟用連線共用。

(繼承來源 HttpWebClientProtocol)
Url

取得或設定用戶端正在要求之 XML Web Service 的基礎 URL。

(繼承來源 WebClientProtocol)
UseDefaultCredentials

取得或設定值,指出是否將 Credentials 屬性設為 DefaultCredentials 屬性的值。

(繼承來源 WebClientProtocol)
UserAgent

針對隨著每個要求所傳送的使用者代理標頭,取得或設定值。

(繼承來源 HttpWebClientProtocol)

方法

Abort()

取消對 XML Web Service 方法的要求。

(繼承來源 WebClientProtocol)
BeginInvoke(String, String, Object[], AsyncCallback, Object)

啟動 XML Web Service 方法的非同步引動過程。

(繼承來源 HttpSimpleClientProtocol)
CancelAsync(Object)

取消對 XML Web Service 方法的非同步呼叫,除非呼叫已完成。

(繼承來源 HttpWebClientProtocol)
CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
EndInvoke(IAsyncResult)

使用 HTTP 完成 XML Web Service 方法的非同步引動過程。

(繼承來源 HttpSimpleClientProtocol)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已過時。

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetWebRequest(Uri)

為指定的 URI 建立 WebRequest 執行個體。

GetWebResponse(WebRequest)

從對 XML Web Service 方法的同步要求傳回回應。

(繼承來源 HttpWebClientProtocol)
GetWebResponse(WebRequest, IAsyncResult)

從對 XML Web Service 方法的非同步要求傳回回應。

(繼承來源 HttpWebClientProtocol)
InitializeLifetimeService()
已過時。

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
Invoke(String, String, Object[])

使用 HTTP 叫用 XML Web Service 方法。

(繼承來源 HttpSimpleClientProtocol)
InvokeAsync(String, String, Object[], SendOrPostCallback)

非同步叫用指定的方法。

(繼承來源 HttpSimpleClientProtocol)
InvokeAsync(String, String, Object[], SendOrPostCallback, Object)

當維護相關聯的狀態時,以非同步方式叫用指定的方法。

(繼承來源 HttpSimpleClientProtocol)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)

適用於

另請參閱