BasicHttpBinding コンストラクター

定義

BasicHttpBinding クラスの新しいインスタンスを初期化します。

オーバーロード

BasicHttpBinding()

BasicHttpBinding クラスの新しいインスタンスを初期化します。

BasicHttpBinding(BasicHttpSecurityMode)

バインドで使用されるセキュリティの種類を指定して、BasicHttpBinding クラスの新しいインスタンスを初期化します。

BasicHttpBinding(String)

構成名で指定されたバインディングを使用して、BasicHttpBinding クラスの新しいインスタンスを初期化します。

BasicHttpBinding()

ソース:
BasicHttpBinding.cs
ソース:
BasicHttpBinding.cs
ソース:
BasicHttpBinding.cs

BasicHttpBinding クラスの新しいインスタンスを初期化します。

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

        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

注釈

使用される BasicHttpSecurityMode の既定値は、SOAP メッセージが保護されず、クライアントが認証されないことを指定する None です。

適用対象

BasicHttpBinding(BasicHttpSecurityMode)

ソース:
BasicHttpBinding.cs
ソース:
BasicHttpBinding.cs
ソース:
BasicHttpBinding.cs

バインドで使用されるセキュリティの種類を指定して、BasicHttpBinding クラスの新しいインスタンスを初期化します。

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)

パラメーター

securityMode
BasicHttpSecurityMode

SOAP メッセージと共に、およびクライアントに対して使用されるセキュリティの種類を指定する BasicHttpSecurityMode の値。

        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

注釈

使用される BasicHttpSecurityMode の既定値は、SOAP メッセージが保護されず、クライアントが認証されないことを指定する None です。

適用対象

BasicHttpBinding(String)

構成名で指定されたバインディングを使用して、BasicHttpBinding クラスの新しいインスタンスを初期化します。

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

パラメーター

configurationName
String

BasicHttpBindingElement のバインド構成の名前。

例外

構成名 configurationName を持つバインディング要素が見つかりませんでした。

次の例では、構成名 "BasicHttpBinding" で指定されたバインドを使用して、myBinding クラスの新しいインスタンスを初期化します。 サービスの構成ファイルの中に、バインド セクションを作成する必要があります。

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

次に、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

適用対象