我有一个 WCF 服务,它有一个 http 终结点,我想添加另一个具有不同绑定的 http 端点地址。该服务未托管在 IIS 中,因此设置了多个站点绑定已启用是没有用的。
我正在尝试这样的事情。
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="ServiceBehaviorConfiguration"
name="ServerService">
<endpoint address="http://localhost:6732/ServerService" binding="webHttpBinding" behaviorConfiguration="webby"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:800/ServerService" binding="basicHttpBinding"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:800/ServerService" />
<add baseAddress="http://localhost:6732/ServerService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
尝试类似
下面显示的配置。它通过单个端口公开多个终结点,但我相信 WCF 支持这种配置模式。
<services>
<service behaviorConfiguration="ServiceBehaviorConfiguration"
name="ServerService">
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="webby"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="basic"
binding="basicHttpBinding"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:800/ServerService" />
</baseAddresses>
</host>
</service>
</services>
您可以创建两个服务,每个服务都有自己不同的 baseAddress,但它们的内部终结点是相同的。