Partager via


BasicHttpBinding Constructeurs

Définition

Initialise une nouvelle instance de la classe BasicHttpBinding.

Surcharges

BasicHttpBinding()

Initialise une nouvelle instance de la classe BasicHttpBinding.

BasicHttpBinding(BasicHttpSecurityMode)

Initialise une nouvelle instance de la classe BasicHttpBinding avec un type spécifié de sécurité utilisé par la liaison.

BasicHttpBinding(String)

Initialise une nouvelle instance de la classe BasicHttpBinding avec une liaison spécifiée par son nom de configuration.

BasicHttpBinding()

Initialise une nouvelle instance de la classe BasicHttpBinding.

public:
 BasicHttpBinding();
public BasicHttpBinding ();
Public Sub New ()

Exemples

        BasicHttpBinding binding = new BasicHttpBinding();
        binding.Name = "binding1";
        binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        binding.Security.Mode = BasicHttpSecurityMode.None;

        Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");
        Uri address = new Uri("http://localhost:8000/servicemodelsamples/service/calc");

        // Create a ServiceHost for the CalculatorService type and provide the base address.
        ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

        serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address);

        // 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 binding As BasicHttpBinding = New BasicHttpBinding()
binding.Name = "binding1"
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
binding.Security.Mode = BasicHttpSecurityMode.None

Dim baseAddress As Uri = New Uri("http://localhost:8000/servicemodelsamples/service")
Dim address As Uri = New Uri("http://localhost:8000/servicemodelsamples/service/calc")

' Create a ServiceHost for the CalculatorService type and provide the base address.
Using serviceHost As ServiceHost = New ServiceHost(GetType(CalculatorService), baseAddress)

    serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, address)

    ' Open the ServiceHost 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 ServiceHost to shutdown the service.
    serviceHost.Close()
End Using

Remarques

La valeur par défaut utilisée pour BasicHttpSecurityMode est None. Cette valeur indique que le message SOAP n'est pas sécurisé et que le client n'est pas authentifié.

S’applique à

BasicHttpBinding(BasicHttpSecurityMode)

Initialise une nouvelle instance de la classe BasicHttpBinding avec un type spécifié de sécurité utilisé par la liaison.

public:
 BasicHttpBinding(System::ServiceModel::BasicHttpSecurityMode securityMode);
public BasicHttpBinding (System.ServiceModel.BasicHttpSecurityMode securityMode);
new System.ServiceModel.BasicHttpBinding : System.ServiceModel.BasicHttpSecurityMode -> System.ServiceModel.BasicHttpBinding
Public Sub New (securityMode As BasicHttpSecurityMode)

Paramètres

securityMode
BasicHttpSecurityMode

Valeur de BasicHttpSecurityMode qui spécifie le type de sécurité utilisé avec le message SOAP et pour le client.

Exemples

        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Message);
        binding.Name = "binding1";
        binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        BasicHttpSecurityMode sMode = binding.Security.Mode;

        Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");
        Uri address = new Uri("http://localhost:8000/servicemodelsamples/service/calc");

        // Create a ServiceHost for the CalculatorService type and provide the base address.
        ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

        serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address);

        // 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 binding As BasicHttpBinding = New BasicHttpBinding(BasicHttpSecurityMode.Message)
binding.Name = "binding1"
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
binding.Security.Mode = BasicHttpSecurityMode.None

Dim baseAddress As Uri = New Uri("http://localhost:8000/servicemodelsamples/service")
Dim address As Uri = New Uri("http://localhost:8000/servicemodelsamples/service/calc")

' Create a ServiceHost for the CalculatorService type and provide the base address.
Using serviceHost As ServiceHost = New ServiceHost(GetType(CalculatorService), baseAddress)

    serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, address)

    ' Open the ServiceHost 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 ServiceHost to shutdown the service.
    serviceHost.Close()
End Using

Remarques

La valeur par défaut utilisée pour BasicHttpSecurityMode est None. Cette valeur indique que le message SOAP n'est pas sécurisé et que le client n'est pas authentifié.

S’applique à

BasicHttpBinding(String)

Initialise une nouvelle instance de la classe BasicHttpBinding avec une liaison spécifiée par son nom de configuration.

public:
 BasicHttpBinding(System::String ^ configurationName);
public BasicHttpBinding (string configurationName);
new System.ServiceModel.BasicHttpBinding : string -> System.ServiceModel.BasicHttpBinding
Public Sub New (configurationName As String)

Paramètres

configurationName
String

Nom de configuration de liaison pour BasicHttpBindingElement.

Exceptions

La liaison contenant le nom de configuration configurationName est introuvable.

Exemples

Cet exemple initialise une nouvelle classe BasicHttpBinding avec une liaison spécifiée par son nom de configuration "myBinding". Vous devez créer une section de liaisons dans le fichier de configuration du service.

BasicHttpBinding binding = new BasicHttpBinding("myBinding");
binding.Name = "binding1";
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.Security.Mode = BasicHttpSecurityMode.Message;

BasicHttpSecurity security = binding.Security;
BasicHttpMessageSecurity msgSecurity = security.Message;

SecurityAlgorithmSuite sas = msgSecurity.AlgorithmSuite;
BasicHttpMessageCredentialType credType = msgSecurity.ClientCredentialType;

Console.WriteLine("The algorithm suite used is {0}", sas.ToString());
Console.WriteLine("The client credential type used is {0}", credType.ToString());
Dim binding As BasicHttpBinding = New BasicHttpBinding()
binding.Name = "binding1"
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
binding.Security.Mode = BasicHttpSecurityMode.Message

Dim security As BasicHttpSecurity = binding.Security
Dim msgSecurity As BasicHttpMessageSecurity = security.Message

Dim sas As SecurityAlgorithmSuite = msgSecurity.AlgorithmSuite
Dim credType As BasicHttpMessageCredentialType = msgSecurity.ClientCredentialType

Console.WriteLine("The algorithm suite used is {0}", sas.ToString())
Console.WriteLine("The client credential type used is {0}", credType.ToString())

Vous devez ensuite spécifier le nom de la configuration de liaison dans l’appel au constructeur BasicHttpBinding.

BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "binding1";
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.Security.Mode = BasicHttpSecurityMode.None;

Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");
Uri address = new Uri("http://localhost:8000/servicemodelsamples/service/calc");

// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
    serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address);

    // 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 binding As BasicHttpBinding = New BasicHttpBinding("BasicBinding")
binding.Name = "binding1"
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
binding.Security.Mode = BasicHttpSecurityMode.None

Dim baseAddress As Uri = New Uri("http://localhost:8000/servicemodelsamples/service")
Dim address As Uri = New Uri("http://localhost:8000/servicemodelsamples/service/calc")

' Create a ServiceHost for the CalculatorService type and provide the base address.
Using serviceHost As ServiceHost = New ServiceHost(GetType(CalculatorService), baseAddress)

    serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, address)

    ' Open the ServiceHost 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 ServiceHost to shutdown the service.
    serviceHost.Close()
End Using

S’applique à