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 元素。

适用于