次のようなものを持つことができます(セルフホスティングを仮定すると、完全なサービスアドレスを自分で実際に決定できるためです-IISでホスティングすると、サービスアドレスは.svc
ファイルが存在する場所によって最も決定されます):
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="YourNamespace.YourService" behaviorConfiguration="Default">
<endpoint name="Default"
address="http://YourServer/Services/MyService"
binding="basicHttpBinding"
contract="YourNamespace.IYourService"/>
<endpoint name="TCP"
address="net.tcp://YourServer/ServicesTCP/MyService"
binding="netTcpBinding"
contract="YourNamespace.IYourService"/>
<endpoint name="mex"
address="http://YourServer/Services/MyService/mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<endpoint name="Dual"
address="http://YourServer/Services/MyService/Dual"
binding="wsDualHttpBinding"
clientBaseAddress="http://localhost:8001/client/"
contract="YourNamespace.IYourDualService"/>
</service>
</services>
</system.serviceModel>
これにより、次の 3 つのエンドポイントが定義されます。
http://YourServer/Services/MyService
サービスの HTTP エンドポイント
http://YourServer/Services/MyService/mex
メタデータ交換用のHTTP MEX エンドポイント(サービスの検出可能性)
net.tcp://YourServer/ServicesTCP/MyService
サービスの Net.TCP エンドポイント
もちろん、設定を簡単にするために2 つのベース アドレスを使用することもできます。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="YourNamespace.YourService" behaviorConfiguration="Default">
<host>
<baseAddresses>
<add baseAddress="http://YourServer/Services"/>
<add baseAddress="net.tcp://YourServer/ServicesTCP"/>
</baseAddresses>
</host>
<endpoint name="Default"
address="MyService"
binding="basicHttpBinding"
contract="YourNamespace.IYourService"/>
<endpoint name="TCP"
address="MyService"
binding="netTcpBinding"
contract="YourNamespace.IYourService"/>
<endpoint name="mex"
address="MyService/mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
これにより、同等のサービス エンドポイントが構成されます。
は、コールバック メカニズムwsDualHttpBinding
に少なくとも が必要であるという点で異なりclientBaseAddress
ます (WCF サービスはクライアントにコールバックして、ステータス メッセージなどを送り返します)。wsHttpBinding
- 別途行う必要があります。しかし、基本的には- それはまだほとんどすべて同じことです....
更新:トピックを読んだ後(私があまり頻繁に使用するものではありません)、二重通信は を使用しても実際に可能であるように見えnetTcpBinding
ますが、サービスを自己ホストしている場合にのみ - IIS は二重通信をサポートしていませんnetTcpBinding
.
二重サービスを作成するには、追加の手順と追加のコードが必要です。そのため、非二重basicHttpBinding
または二重のサービスをwsHttpBinding
同時に使用することはできません。したがって、この例で を使用して別のエンドポイントを持つことは、実際には意味がありません。wsDualHttpBinding
なぜなら、そのサービスは実際には二重である必要があるためです (その後、wsDualHttpBinding
andを使用できますnetTcpBinding
) - または二重ではない - その後basicHttpBinding
、 、wsHttpBinding
、netTcpBinding
およびさらにいくつかを使用できます。"エキゾチックなバインディング (MSMQ、名前付きパイプなど)