HttpSimpleClientProtocol 類別

定義

表示使用簡單 HTTP-GET 和 HTTP-POST 通訊協定繫結,與 XML Web Service 進行通訊所用的基底類別。

public ref class HttpSimpleClientProtocol abstract : System::Web::Services::Protocols::HttpWebClientProtocol
public abstract class HttpSimpleClientProtocol : System.Web.Services.Protocols.HttpWebClientProtocol
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class HttpSimpleClientProtocol : System.Web.Services.Protocols.HttpWebClientProtocol
type HttpSimpleClientProtocol = class
    inherit HttpWebClientProtocol
[<System.Runtime.InteropServices.ComVisible(true)>]
type HttpSimpleClientProtocol = class
    inherit HttpWebClientProtocol
Public MustInherit Class HttpSimpleClientProtocol
Inherits HttpWebClientProtocol
繼承
衍生
屬性

範例

下列程式碼範例是下列 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 服務。

#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

備註

這個類別會指定大部分的實作,以使用編碼器透過 HTTP 與 XML Web 服務通訊,以將參數編碼,並將值傳回為一般 MIME 格式。 這些編碼器衍生自 MimeFormatter 類別。 根據預設,衍生自 HttpSimpleClientProtocol 的 Proxy 類別會使用 application/x-www-form-urlencoded MIME 類型和純 XML 回應來編碼參數。 不過,您可以使用 屬性來指定 HttpMethodAttribute 自訂 mime 格式器,不過,不支援將它整合到服務描述和 Proxy 產生中。

Notes to Inheritors: 當您覆寫此類別時,可以在衍生類別中引進特定 XML Web 服務類型特有的方法。 方法只會擷取參數,並呼叫基類來執行與月臺通訊的工作。 如果引進的方法是非同步,請呼叫 BeginInvokeEndInvoke 方法。 如果引進的方法是同步的,請呼叫 Invoke 方法。 覆寫的建構函式通常會將 Url 屬性設定為 XML Web 服務方法的 URI。

Web 服務描述語言工具 (Wsdl.exe) 為指定的服務描述產生 衍生類別 HttpSimpleClientProtocol

建構函式

HttpSimpleClientProtocol()

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

屬性

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 方法的非同步引動過程。

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 方法的非同步引動過程。

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

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

(繼承來源 MarshalByRefObject)
GetService(Type)

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

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetWebRequest(Uri)

建立指定 URL 的 WebRequest

(繼承來源 HttpWebClientProtocol)
GetWebResponse(WebRequest)

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

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

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

(繼承來源 HttpWebClientProtocol)
InitializeLifetimeService()
已淘汰.

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

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

使用 HTTP 叫用 XML Web Service 方法。

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

非同步叫用指定的方法。

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

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

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

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

(繼承來源 MarshalByRefObject)
ToString()

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

(繼承來源 Component)

事件

Disposed

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

(繼承來源 Component)

適用於

執行緒安全性

此型別具備執行緒安全。

另請參閱