これはクライアント側のものですか??
その場合は、WsHttpBinding のインスタンスと EndpointAddress を作成し、これら 2 つをパラメーターとして受け取るプロキシ クライアント コンストラクターに渡す必要があります。
// using System.ServiceModel;
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpoint = new EndpointAddress(new Uri("http://localhost:9000/MyService"));
MyServiceClient client = new MyServiceClient(binding, endpoint);
サーバー側にある場合は、ServiceHost の独自のインスタンスをプログラムで作成し、それに適切なサービス エンドポイントを追加する必要があります。
ServiceHost svcHost = new ServiceHost(typeof(MyService), null);
svcHost.AddServiceEndpoint(typeof(IMyService),
new WSHttpBinding(),
"http://localhost:9000/MyService");
もちろん、これらのサービス エンドポイントを複数、サービス ホストに追加することもできます。完了したら、.Open() メソッドを呼び出してサービス ホストを開く必要があります。
動的に (実行時に) 使用する構成を選択できるようにする場合は、それぞれに一意の名前を付けて複数の構成を定義し、その構成を使用して (サービス ホストまたはプロキシ クライアントの) 適切なコンストラクターを呼び出すことができます。使用したい名前。
たとえば、次のように簡単に設定できます。
<endpoint address="http://mydomain/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IASRService"
contract="ASRService.IASRService"
name="WSHttpBinding_IASRService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="https://mydomain/MyService2.svc"
binding="wsHttpBinding" bindingConfiguration="SecureHttpBinding_IASRService"
contract="ASRService.IASRService"
name="SecureWSHttpBinding_IASRService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://mydomain/MyService3.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IASRService"
contract="ASRService.IASRService"
name="NetTcpBinding_IASRService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
(3 つの異なる名前、異なる bindingConfigurations を指定することによる異なるパラメーター) を選択し、適切なものを選択してサーバー (またはクライアント プロキシ) をインスタンス化します。
ただし、サーバーとクライアントのどちらの場合でも、実際にサービス ホストまたはプロキシ クライアントを作成する前に選択する必要があります。いったん作成されると、これらは不変です。起動して実行すると、微調整することはできません。
マルク