ReliableSessionBindingElement 類別

定義

表示繫結項目,此繫結項目可以產生端點之間之可靠工作階段所需要的傳送和接收通道。Represents the binding element that can produce the sending and receiving channels required for a reliable session between endpoints.

public ref class ReliableSessionBindingElement sealed : System::ServiceModel::Channels::BindingElement, System::ServiceModel::Description::IPolicyExportExtension
public sealed class ReliableSessionBindingElement : System.ServiceModel.Channels.BindingElement, System.ServiceModel.Description.IPolicyExportExtension
type ReliableSessionBindingElement = class
    inherit BindingElement
    interface IPolicyExportExtension
Public NotInheritable Class ReliableSessionBindingElement
Inherits BindingElement
Implements IPolicyExportExtension
繼承
ReliableSessionBindingElement
實作

範例

ReliableSessionBindingElement 可以加入至任何自訂繫結。The ReliableSessionBindingElement can be added to any custom binding. 這個動作會由下列組態項目完成。This is done using the following configuration elements.

<bindings>  
    <customBinding>  
        <binding configurationName="ReliabilityHTTP">  
            <reliableSession/>  
        </binding>  
    </customBinding>  
</bindings>  

下列範例程式碼將示範如何透過程式碼來使用 ReliableSessionBindingElementThe following sample code demonstrates how to use ReliableSessionBindingElement in code.

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

備註

提供工作階段,並選擇性地提供已排序的訊息傳遞。Provides sessions and optionally provides ordered message delivery. 這個實作的工作階段可以跨 SOAP 和傳輸媒介。This implemented session can cross SOAP and transport intermediaries.

每個繫結項目都代表傳送或接收訊息時的一個處理步驟。Each binding element represents a processing step when sending or receiving messages. 繫結項目會在執行階段建立通道處理站和接聽程式,它們是在傳送和接收訊息時所需要之傳出和傳入通道堆疊的必要建置項目。At runtime, binding elements create the channel factories and listeners that are necessary to build outgoing and incoming channel stacks required to send and receive messages. ReliableSessionBindingElement 在堆疊中提供選擇性的層級,而透過該層級可以在端點之間建立可靠工作階段,並設定這個工作階段的行為。The ReliableSessionBindingElement provides an optional layer in the stack that can establish a reliable session between endpoints and configure the behavior of this session.

ReliableSessionBindingElement 會在下表中的標準繫結上提供。The ReliableSessionBindingElement is provided on the standard bindings in the following table.

繫結Binding 預設Default
NetTcpBinding OffOff
WSHttpBinding OffOff
WSDualHttpBinding 開啟 (必要)On (required)

建構函式

ReliableSessionBindingElement()

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

ReliableSessionBindingElement(Boolean)

初始化 ReliableSessionBindingElement 類別的新執行個體,該執行個體會指定訊息傳遞是否必須保留訊息傳送時的順序。Initializes a new instance of the ReliableSessionBindingElement class that specifies whether message delivery must preserve the order in which messages are sent.

屬性

AcknowledgementInterval

取得或設定傳送確認到可靠通道 (由處理站所建立) 之訊息來源前,目的端需等候的時間間隔。Gets or sets the interval of time that a destination waits before sending an acknowledgment to the message source on reliable channels that are created by the factory.

FlowControlEnabled

取得或設定值,這個值會指出可靠工作階段是否已啟用流量控制。Gets or sets a value that indicates whether the reliable session has flow control enabled.

InactivityTimeout

取得或設定服務在關閉之前維持在非作用狀態的時間間隔。Gets or sets an interval of time that a service remains inactive before closing.

MaxPendingChannels

取得或設定可以在可靠工作階段期間擱置的最大通道數。Gets or sets the largest number of channels that can be pending during the reliable session.

MaxRetryCount

取得或設定訊息在可靠工作階段期間嘗試傳輸的最大次數。Gets or sets the maximum number of times that a message attempts to be transferred during the reliable session.

MaxTransferWindowSize

取得或設定可以存在傳送緩衝區或接收緩衝區中的最大訊息數。Gets or sets the largest number of messages that can exist in either the send buffer or the receive buffer.

Ordered

取得或設定值,這個值會指出訊息傳遞是否必須保留訊息傳送時的順序。Gets or sets a value that indicates whether message delivery must preserve the order in which messages are sent.

ReliableMessagingVersion

取得或設定繫結項目指定的 WS-ReliableMessaging 的版本。Gets or sets the version of WS-ReliableMessaging specified by the binding element.

方法

BuildChannelFactory<TChannel>(BindingContext)

傳回處理站,該處理站會建立支援可靠工作階段之指定型別的通道。Returns a factory that creates a channel of a specified type that supports a reliable session.

BuildChannelListener<TChannel>(BindingContext)

傳回接聽程式,此接聽程式會接受支援可靠工作階段之指定型別的通道。Returns a listener that accepts a channel of a specified type that supports a reliable session.

CanBuildChannelFactory<TChannel>(BindingContext)

傳回值,這個值會指出是否可以為可支援可靠工作階段的通道和內容建置通道處理站。Returns a value that indicates whether the channel factory can be built for the channel and context provided that can support a reliable session.

CanBuildChannelListener<TChannel>(BindingContext)

傳回值,這個值表示是否可以為可支援可靠工作階段的通道和內容建置通道接聽程式。Returns a value that indicates whether the channel listener can be built for the channel and context provided that can support a reliable session.

Clone()

建立目前可靠工作階段繫結項目的複本。Creates a copy of the current reliable session 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)

從型別之繫結內容取得該指定型別的屬性。Gets a property of the specified type from its binding context.

GetType()

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

(繼承來源 Object)
MemberwiseClone()

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

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

明確介面實作

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

將可靠工作階段繫結項目中包含的資訊對應至 WSDL 項目,該項目可讓遠端端點使用可靠工作階段來存取服務。Maps the information contained in the reliable session binding element into the WSDL elements that enable a remote endpoint to access the service with a reliable session.

適用於