ReliableSessionBindingElement 類別

定義

表示繫結項目,此繫結項目可以產生端點之間之可靠工作階段所需要的傳送和接收通道。

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

範例

ReliableSessionBindingElement 可以加入至任何自訂繫結。 這個動作會由下列組態項目完成。

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

下列範例程式碼將示範如何透過程式碼來使用 ReliableSessionBindingElement

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

備註

提供工作階段,並選擇性地提供已排序的訊息傳遞。 這個實作的工作階段可以跨 SOAP 和傳輸媒介。

每個繫結項目都代表傳送或接收訊息時的一個處理步驟。 繫結項目會在執行階段建立通道處理站和接聽程式,它們是在傳送和接收訊息時所需要之傳出和傳入通道堆疊的必要建置項目。 ReliableSessionBindingElement 在堆疊中提供選擇性的層級,而透過該層級可以在端點之間建立可靠工作階段,並設定這個工作階段的行為。

ReliableSessionBindingElement 會在下表中的標準繫結上提供。

繫結 預設
NetTcpBinding 關閉
WSHttpBinding 關閉
WSDualHttpBinding 開啟 (必要)

建構函式

ReliableSessionBindingElement()

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

ReliableSessionBindingElement(Boolean)

初始化 ReliableSessionBindingElement 類別的新執行個體,該執行個體會指定訊息傳遞是否必須保留訊息傳送時的順序。

屬性

AcknowledgementInterval

取得或設定傳送確認到可靠通道 (由處理站所建立) 之訊息來源前,目的端需等候的時間間隔。

FlowControlEnabled

取得或設定值,這個值會指出可靠工作階段是否已啟用流量控制。

InactivityTimeout

取得或設定服務在關閉之前維持在非作用狀態的時間間隔。

MaxPendingChannels

取得或設定可以在可靠工作階段期間擱置的最大通道數。

MaxRetryCount

取得或設定訊息在可靠工作階段期間嘗試傳輸的最大次數。

MaxTransferWindowSize

取得或設定可以存在傳送緩衝區或接收緩衝區中的最大訊息數。

Ordered

取得或設定值,這個值會指出訊息傳遞是否必須保留訊息傳送時的順序。

ReliableMessagingVersion

取得或設定繫結項目指定的 WS-ReliableMessaging 的版本。

方法

BuildChannelFactory<TChannel>(BindingContext)

傳回處理站,該處理站會建立支援可靠工作階段之指定型別的通道。

BuildChannelListener<TChannel>(BindingContext)

傳回接聽程式,此接聽程式會接受支援可靠工作階段之指定型別的通道。

BuildChannelListener<TChannel>(BindingContext)

初始化通道接聽項,以便從繫結內容接受指定之類型的通道。

(繼承來源 BindingElement)
CanBuildChannelFactory<TChannel>(BindingContext)

傳回值,這個值會指出是否可以為可支援可靠工作階段的通道和內容建置通道處理站。

CanBuildChannelListener<TChannel>(BindingContext)

傳回值,這個值會指出是否可以為可支援可靠工作階段的通道和內容建置通道接聽程式。

CanBuildChannelListener<TChannel>(BindingContext)

傳回值,指出繫結項目是否可以建置特定通道型別的通道接聽程式。

(繼承來源 BindingElement)
Clone()

建立目前可靠工作階段繫結項目的複本。

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

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

從型別之繫結內容取得該指定型別的屬性。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

將可靠工作階段繫結項目中包含的資訊對應至 WSDL 項目,該項目可讓遠端端點使用可靠工作階段來存取服務。

適用於