ReliableSessionBindingElement Klasa

Definicja

Reprezentuje element powiązania, który może generować kanały wysyłania i odbierania wymagane dla niezawodnej sesji między punktami końcowymi.

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
Dziedziczenie
ReliableSessionBindingElement
Implementuje

Przykłady

Element ReliableSessionBindingElement można dodać do dowolnego powiązania niestandardowego. Odbywa się to przy użyciu następujących elementów konfiguracji.

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

Poniższy przykładowy kod demonstruje sposób użycia ReliableSessionBindingElement w kodzie.

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

Uwagi

Udostępnia sesje i opcjonalnie udostępnia uporządkowane dostarczanie komunikatów. Ta zaimplementowana sesja może przekraczać protokół SOAP i pośredników transportowych.

Każdy element powiązania reprezentuje krok przetwarzania podczas wysyłania lub odbierania komunikatów. W czasie wykonywania elementy powiązania tworzą fabryki kanałów i odbiorniki, które są niezbędne do tworzenia stosów kanałów wychodzących i przychodzących wymaganych do wysyłania i odbierania komunikatów. Element ReliableSessionBindingElement udostępnia opcjonalną warstwę w stosie, która może ustanowić niezawodną sesję między punktami końcowymi i skonfigurować zachowanie tej sesji.

Element ReliableSessionBindingElement jest udostępniany na powiązaniach standardowych w poniższej tabeli.

Wiązanie Domyślny
NetTcpBinding Wyłączone
WSHttpBinding Wyłączone
WSDualHttpBinding Włączone (wymagane)

Konstruktory

ReliableSessionBindingElement()

Inicjuje nowe wystąpienie klasy ReliableSessionBindingElement.

ReliableSessionBindingElement(Boolean)

Inicjuje ReliableSessionBindingElement nowe wystąpienie klasy, które określa, czy dostarczanie komunikatów musi zachować kolejność wysyłania komunikatów.

Właściwości

AcknowledgementInterval

Pobiera lub ustawia interwał czasu oczekiwania miejsca docelowego przed wysłaniem potwierdzenia do źródła komunikatów w niezawodnych kanałach tworzonych przez fabrykę.

FlowControlEnabled

Pobiera lub ustawia wartość wskazującą, czy sesja niezawodna ma włączoną kontrolę przepływu.

InactivityTimeout

Pobiera lub ustawia interwał czasu, przez który usługa pozostaje nieaktywna przed zamknięciem.

MaxPendingChannels

Pobiera lub ustawia największą liczbę kanałów, które mogą być oczekujące podczas niezawodnej sesji.

MaxRetryCount

Pobiera lub ustawia maksymalną liczbę prób przeniesienia komunikatu podczas niezawodnej sesji.

MaxTransferWindowSize

Pobiera lub ustawia największą liczbę komunikatów, które mogą istnieć w buforze wysyłania lub buforze odbierania.

Ordered

Pobiera lub ustawia wartość wskazującą, czy dostarczanie komunikatów musi zachować kolejność wysyłania komunikatów.

ReliableMessagingVersion

Pobiera lub ustawia wersję WS-ReliableMessaging określoną przez element powiązania.

Metody

BuildChannelFactory<TChannel>(BindingContext)

Zwraca fabrykę, która tworzy kanał określonego typu, który obsługuje niezawodną sesję.

BuildChannelListener<TChannel>(BindingContext)

Zwraca odbiornik, który akceptuje kanał określonego typu, który obsługuje niezawodną sesję.

BuildChannelListener<TChannel>(BindingContext)

Inicjuje odbiornik kanału, aby akceptował kanały określonego typu z kontekstu powiązania.

(Odziedziczone po BindingElement)
CanBuildChannelFactory<TChannel>(BindingContext)

Zwraca wartość wskazującą, czy fabrykę kanałów można skompilować dla kanału i kontekstu, pod warunkiem, że może obsługiwać niezawodną sesję.

CanBuildChannelListener<TChannel>(BindingContext)

Zwraca wartość wskazującą, czy odbiornik kanału można skompilować dla kanału i kontekstu, pod warunkiem, że może obsługiwać niezawodną sesję.

CanBuildChannelListener<TChannel>(BindingContext)

Zwraca wartość wskazującą, czy element powiązania może skompilować odbiornik dla określonego typu kanału.

(Odziedziczone po BindingElement)
Clone()

Tworzy kopię bieżącego elementu powiązania niezawodnej sesji.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetProperty<T>(BindingContext)

Pobiera właściwość określonego typu z kontekstu powiązania.

GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

Mapuje informacje zawarte w element powiązania niezawodnej sesji na elementy WSDL, które umożliwiają zdalny punkt końcowy uzyskiwania dostępu do usługi za pomocą niezawodnej sesji.

Dotyczy