BasicHttpBinding Constructor (String)

 

Initializes a new instance of the BasicHttpBinding class with a binding specified by its configuration name.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Public Sub New (
	configurationName As String
)

Parameters

configurationName
Type: System.String

The binding configuration name for the BasicHttpBindingElement.

Exception Condition
ConfigurationErrorsException

The binding with the configuration name configurationName was not found.

This example initializes a new BasicHttpBinding class with a binding specified by the configuration name BasicBinding. You must create a bindings section in the service's configuration file.

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())

Then the name of the binding configuration is specified in the call to the BasicHttpBinding constructor.

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

.NET Framework
Available since 3.0
Return to top
Show: