ReliableSessionBindingElement Class
Assembly: System.ServiceModel (in system.servicemodel.dll)
'Declaration Public NotInheritable Class ReliableSessionBindingElement Inherits BindingElement Implements IPolicyExportExtension 'Usage Dim instance As ReliableSessionBindingElement
public final class ReliableSessionBindingElement extends BindingElement implements IPolicyExportExtension
public final class ReliableSessionBindingElement extends BindingElement implements IPolicyExportExtension
Not applicable.
Provides sessions and optionally provides ordered message delivery. 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 necessary to build outgoing and incoming channel stacks required to send and receive messages. The ReliableSessionBindingElement provides an optional layer in the stack that can establish a reliable session between endpoints and configure the behavior of this session.
The ReliableSessionBindingElement is provided on the standard bindings in the following table.
| Binding | Default |
|---|---|
| Off | |
| Off | |
| (Must be) On |
The ReliableSessionBindingElement may be added to any custom binding. This is done using the following configuration elements.
<bindings>
<customBinding>
<binding configurationName=”ReliabilityHTTP”>
<reliableSession/>
</binding>
</customBinding>
</bindings>
The following sample code illustrates 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(); }
System.ServiceModel.Channels.BindingElement
System.ServiceModel.Channels.ReliableSessionBindingElement
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.