我正在开发一个 wcf 项目我有 1 个服务和 2 个合同(2 个端点)和 1 个服务和 1 个合同(1 个端点)我想为我的两个服务制作 1 个单一的 ServiceHost。我可以为 2 项服务制作 2 台主机,但我只需要 1 台主机。
ServiceHost myService =
new ServiceHost(typeof(CustomerOrder),
new Uri("net.tcp://localhost:9191/T1Flondor_Antal"));
ServiceHost myService2 =
new ServiceHost(typeof(ReportServiceCO),
new Uri("net.tcp://localhost:9191/T1Flondor_Antal"));
和配置:
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="T1Flondor_Antal.CustomerOrder"
behaviorConfiguration="T1Flondor_Antal.MessageBehavior">
<endpoint address ="net.tcp://localhost:9191/T1Flondor_Antal/Customer"
binding="netTcpBinding"
contract="T1Flondor_Antal.ICustomer">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address ="net.tcp://localhost:9191/T1Flondor_Antal/Order"
binding="netTcpBinding"
contract="T1Flondor_Antal.IOrder">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
<service name="T1Flondor_Antal.ReportServiceCO"
behaviorConfiguration="T1Flondor_Antal.MessageBehavior">
<endpoint address ="net.tcp://localhost:9191/T1Flondor_Antal/Report"
binding="netTcpBinding"
contract="T1Flondor_Antal.IReport">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="T1Flondor_Antal.MessageBehavior">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>