HttpTransportBindingElement 類別

定義

表示用來指定傳輸訊息之 HTTP 傳輸的繫結項目。Represents the binding element used to specify an HTTP transport for transmitting messages.

public ref class HttpTransportBindingElement : System::ServiceModel::Channels::TransportBindingElement, System::ServiceModel::Description::IPolicyExportExtension, System::ServiceModel::Description::IWsdlExportExtension
public class HttpTransportBindingElement : System.ServiceModel.Channels.TransportBindingElement, System.ServiceModel.Description.IPolicyExportExtension, System.ServiceModel.Description.IWsdlExportExtension
type HttpTransportBindingElement = class
    inherit TransportBindingElement
    interface IPolicyExportExtension
    interface IWsdlExportExtension
Public Class HttpTransportBindingElement
Inherits TransportBindingElement
Implements IPolicyExportExtension, IWsdlExportExtension
繼承
HttpTransportBindingElement
衍生
實作

範例

下列程式碼會示範如何強制使用 HttpTransportBindingElementThe following code shows how to imperatively use the HttpTransportBindingElement.

Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
    // Create a custom binding that contains two binding elements.
    ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
    reliableSession.Ordered = true;

    HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
    httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
    httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

    CustomBinding binding = new CustomBinding(reliableSession, httpTransport);

    // Add an endpoint using that binding.
    serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, "");

    // Add a MEX endpoint.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples");
    serviceHost.Description.Behaviors.Add(smb);
  
    // Open the ServiceHostBase to create listeners and start listening for messages.
    serviceHost.Open();

    // The service can now be accessed.
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.WriteLine();
    Console.ReadLine();

    // Close the ServiceHostBase to shutdown the service.
    serviceHost.Close();
}
Dim baseAddress As New Uri("http://localhost:8000/servicemodelsamples/service")

' Create a ServiceHost for the CalculatorService type and provide the base address.
Using serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
    ' Create a custom binding that contains two binding elements.
    Dim reliableSession As New ReliableSessionBindingElement()
    reliableSession.Ordered = True

    Dim httpTransport As New HttpTransportBindingElement()
    httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous
    httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard

    Dim binding As New CustomBinding(reliableSession, httpTransport)

    ' Add an endpoint using that binding.
    serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, "")

    ' Add a MEX endpoint.
    Dim smb As New ServiceMetadataBehavior()
    smb.HttpGetEnabled = True
    smb.HttpGetUrl = New Uri("http://localhost:8001/servicemodelsamples")
    serviceHost.Description.Behaviors.Add(smb)

    ' Open the ServiceHostBase to create listeners and start listening for messages.
    serviceHost.Open()

    ' The service can now be accessed.
    Console.WriteLine("The service is ready.")
    Console.WriteLine("Press <ENTER> to terminate service.")
    Console.WriteLine()
    Console.ReadLine()

    ' Close the ServiceHostBase to shutdown the service.
    serviceHost.Close()
End Using

HttpTransportBindingElement 也可以在設定檔中使用,如下列設定所示。HttpTransportBindingElement can also be used in a configuration file as shown in the following configuration.

<bindings>  
  <customBinding>  
    <binding name="Binding1">  
      <reliableSession acknowledgementInterval="00:00:00.2000000" enableFlowControl="true"  
                        maxTransferWindowSize="32" inactivityTimeout="00:10:00" maxPendingChannels="128"  
                        maxRetryCount="8" ordered="true" />  
      <security mode="None"/>  
      <httpTransport authenticationScheme="Anonymous" bypassProxyOnLocal="false"  
                    hostNameComparisonMode="StrongWildcard"   
                    proxyAuthenticationScheme="Anonymous" realm=""   
                    useDefaultWebProxy="true" />  
    </binding>  
  </customBinding>  
</bindings>  

備註

HttpTransportBindingElement 類別是一個起點,用來建立實作 HTTP 傳輸通訊協定的自訂繫結。The HttpTransportBindingElement class is the starting point for creating a custom binding that implements the HTTP transport protocol. HTTP 是用於互通性目的的主要傳輸。HTTP is the primary transport used for interoperability purposes. Windows Communication Foundation (WCF)支援此傳輸,以確保與其他非 WCF Web 服務堆疊之間的互通性。This transport is supported by Windows Communication Foundation (WCF) to ensure interoperability with other non-WCF Web services stacks.

WCF 服務模型會使用這個類別來建立 factory 物件,以執行 IChannelFactoryIChannelListener 介面。The WCF service model uses this class to create factory objects that implement the IChannelFactory and IChannelListener interfaces. 然後,這些處理站物件會建立使用 HTTP 通訊協定傳輸 SOAP 訊息的通道和接聽程式。These factory objects, in turn, create the channels and listeners that transmit SOAP messages using the HTTP protocol.

您可以設定這個類別的屬性,以設定其所建立的處理站,例如:AuthenticationSchemeHostNameComparisonModeMaxBufferSizeYou configure the factories that this class creates by setting its properties, such as AuthenticationScheme, HostNameComparisonMode, and MaxBufferSize.

您也可以設定基底類別 TransportBindingElement 的屬性,例如:ManualAddressingMaxReceivedMessageSizeMaxBufferPoolSizeYou can also set properties on the base class, TransportBindingElement, such as ManualAddressing, MaxReceivedMessageSize, and MaxBufferPoolSize. 如需完整的屬性清單,請參閱 TransportBindingElementFor a complete list of properties, see TransportBindingElement.

建構函式

HttpTransportBindingElement()

初始化 HttpTransportBindingElement 類別的新執行個體。Initializes a new instance of the HttpTransportBindingElement class.

HttpTransportBindingElement(HttpTransportBindingElement)

使用另一個繫結項目,初始化 HttpTransportBindingElement 類別的新執行個體。Initializes a new instance of the HttpTransportBindingElement class using another binding element.

屬性

AllowCookies

取得或設定值,這個值會指出用戶端是否接受 Cookie 並依未來要求傳播 Cookie。Gets or sets a value that indicates whether the client accepts cookies and propagates them on future requests.

AuthenticationScheme

取得或設定驗證配置,用於驗證由 HTTP 接聽程式處理的用戶端要求。Gets or sets the authentication scheme used to authenticate client requests being processed by an HTTP listener.

BypassProxyOnLocal

取得或設定值,指出是否忽略本機位址的 Proxy。Gets or sets a value that indicates whether proxies are ignored for local addresses.

DecompressionEnabled

取得或設定是否已啟用傳回壓縮訊息資料至其原始大小與格式的程序。Gets or sets whether the process for returning compressed message data to its original size and format is enabled.

ExtendedProtectionPolicy

取得或設定值,這個值是伺服器用來驗證連入用戶端連線的延伸安全性原則。Gets or sets the value of the extended security policy used by the server to validate incoming client connections.

HostNameComparisonMode

取得或設定值,這個值會指出在比對 URI 時主機名稱是否會用來取用服務。Gets or sets a value that indicates whether the hostname is used to reach the service when matching on the URI.

KeepAliveEnabled

取得或設定值,這個值表示是否要與服務端點建立持續連線。Gets or sets a value that indicates whether to make a persistent connection to a service endpoint.

LegacyExtendedProtectionPolicy
ManualAddressing

取得或設定值,這個值會指出是否需要訊息的手動定址。Gets or sets a value that indicates whether manual addressing of the message is required.

(繼承來源 TransportBindingElement)
MaxBufferPoolSize

取得或設定傳輸所使用之任何緩衝區集區的大小上限 (以位元組為單位)。Gets or sets the maximum size, in bytes, of any buffer pools used by the transport.

(繼承來源 TransportBindingElement)
MaxBufferSize

取得或設定要使用之緩衝區的大小上限。Gets or sets the maximum size of the buffer to use. 對於經過緩衝處理的訊息,這個值與 MaxReceivedMessageSize 相同。For buffered messages this value is the same as MaxReceivedMessageSize. 對於已進行資料流處理的訊息,這個值為 SOAP 標頭的最大大小 (必須在緩衝模式中讀取)。For streamed messages, this value is the maximum size of the SOAP headers, which must be read in buffered mode.

MaxPendingAccepts

取得或設定服務能夠同時接受的最大連線數。Gets or sets the maximum number of connections the service can accept simultaneously.

MaxReceivedMessageSize

取得或設定可接收之可允許的訊息大小上限 (以位元組為單位)。Gets or sets the maximum allowable message size, in bytes, that can be received.

(繼承來源 TransportBindingElement)
MessageHandlerFactory

取得或設定 Http 傳輸訊息處理常式 factory。Gets or sets the Http transport message handler factory.

ProxyAddress

取得或設定 URI,包含用於 HTTP 要求的 Proxy 位址。Gets or sets a URI that contains the address of the proxy to use for HTTP requests.

ProxyAuthenticationScheme

取得或設定驗證配置,用於驗證由 HTTP Proxy 處理的用戶端要求。Gets or sets the authentication scheme used to authenticate client requests being processed by an HTTP proxy.

Realm

取得或設定驗證領域。Gets or sets the authentication realm.

RequestInitializationTimeout

取得或設定要求的初始設定逾時。Gets or sets the requested initialization time out.

Scheme

取得用於傳輸的 URI 配置。Gets the URI scheme for the transport.

TransferMode

取得或設定傳輸模式。Gets or sets the transfer mode.

UnsafeConnectionNtlmAuthentication

取得或設定值,指出伺服器上是否啟用不安全的連線共用。Gets or sets a value that indicates whether Unsafe Connection Sharing is enabled on the server. 如果已啟用,NTLM 驗證會在各 TCP 連線上執行一次。If enabled, NTLM authentication is performed once on each TCP connection.

UseDefaultWebProxy

取得或設定值,指出是否使用全機器 Proxy 設定而非使用者特定設定。Gets or sets a value that indicates whether the machine-wide proxy settings are used rather than the user specific settings.

WebSocketSettings

取得或設定繫結項目的 Web 通訊端組態。Gets or sets the web socket configuration of the binding element.

方法

BuildChannelFactory<TChannel>(BindingContext)

建立可用來建立通道的通道處理站。Creates a channel factory that can be used to create a channel.

BuildChannelListener<TChannel>(BindingContext)

建立指定型別的通道接聽程式。Creates a channel listener of the specified type.

CanBuildChannelFactory<TChannel>(BindingContext)

判斷是否可以建置指定之型別的通道處理站。Determines whether a channel factory of the specified type can be built.

CanBuildChannelListener<TChannel>(BindingContext)

判斷是否可以建置指定之型別的通道接聽項。Determines whether a channel listener of the specified type can be built.

Clone()

建立目前繫結項目複本的新執行個體。Creates a new instance that is a copy of the current binding element.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetProperty<T>(BindingContext)

從指定的 BindingContext{2}中取得屬性。Gets a property from the specified BindingContext.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ShouldSerializeExtendedProtectionPolicy()

傳回值,這個值指出不可能讓 XAML 序列化延伸保護原則。Returns a valueindicating that it is not possible to XAML serialize the extended protection policy.

ShouldSerializeMessageHandlerFactory()

判斷是否應將息處理常式 Factory 序列化。Determines whether the message handler factory should be serialized.

ShouldSerializeWebSocketSettings()

判斷是否應將 Web 通訊端設定序列化。Determines whether the web socket settings should be serialized.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
UpdateAuthenticationSchemes(BindingContext)

更新包含繫結內容的傳輸驗證配置。Updates the transport authentication schemes that contains the binding context.

明確介面實作

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

匯出關於繫結的自訂原則判斷提示。Exports a custom policy assertion about bindings.

IWsdlExportExtension.ExportContract(WsdlExporter, WsdlContractConversionContext)

將自訂的 Web 服務描述語言 (WSDL) 項目寫入為合約產生的 WSDL。Writes custom Web Services Description Language (WSDL) elements into the generated WSDL for a contract.

IWsdlExportExtension.ExportEndpoint(WsdlExporter, WsdlEndpointConversionContext)

將自訂的 Web 服務描述語言 (WSDL) 項目寫入為端點產生的 WSDL。Writes custom Web Services Description Language (WSDL) elements into the generated WSDL for an endpoint.

適用於