下面是我的WCF服务配置。我使用2 ServiceHost托管2种服务类型。它们使用相同的基址,但对端点使用不同的相对地址。
但我有这个错误,为什么?
无法启动服务。System.InvalidOperationException: ChannelDispatcher at 'http://earth:1111/‘与合同’IHttpGetHelpPageAndMetadataContract‘不能打开IChannelListener。-> System.InvalidOperationException: URI 'http://earth:1111/'.的注册已经存在
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.IIS.IISServiceType">
<endpoint address="iis" binding="basicHttpBinding" name="iis"
contract="Distributed.Troubleshooting.System.IIS.IISServiceContract" />
<endpoint address="iismex" binding="mexHttpBinding" bindingConfiguration=""
name="iismex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://Earth:1111/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.SQL.SQLServiceType">
<endpoint address="sql" binding="basicHttpBinding" name="sql"
contract="Distributed.Troubleshooting.System.SQL.SQLServiceContract" />
<endpoint address="sqlmex" binding="mexHttpBinding" bindingConfiguration=""
name="sqlmex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://Earth:1111/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>一些更荒谬的发现:
我将配置更改为:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.IIS.IISServiceType">
<endpoint address="http://Earth:1111/iis" binding="basicHttpBinding" name="iis"
contract="Distributed.Troubleshooting.System.IIS.IISServiceContract" />
<endpoint address="http://Earth:1111/iismex" binding="mexHttpBinding" bindingConfiguration=""
name="iismex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://Earth:1111/iis" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.SQL.SQLServiceType">
<endpoint address="http://Earth:1111/sql" binding="basicHttpBinding" name="sql"
contract="Distributed.Troubleshooting.System.SQL.SQLServiceContract" />
<endpoint address="http://Earth:1111/sqlmex" binding="mexHttpBinding" bindingConfiguration=""
name="sqlmex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://Earth:1111/sql" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>然后,我发现我可以在Visual中使用“”,地址如下:
发布于 2014-03-24 15:00:36
可以使用相同的基址托管多个服务。将HttpHelpPageEnabled和all ServiceDebugBehavior的HttpsHelpPageEnabled属性设置为false,然后它就可以工作了。
:默认情况下,在主机的行为描述集合中始终有一个注册的ServiceDebugBehavior,即使没有明确指定它(我只尝试了通过编程信任和ServiceHost类,而不是通过XML )。因此,您应该添加一个显式的ServiceDebugBehavior并设置上述属性。IncludeExceptionDetailInFaults属性可以是true。
发布于 2011-11-30 15:54:10
您是否尝试过移除一个服务块并将端点组合成一个?
我看不出你为什么要把它们分开。
确保基址+端点地址是唯一的。
发布于 2011-11-30 15:58:51
您不能以相同的基址承载两个服务。
您需要将另一个主机放在不同的端口或地址上。
有点像
http://Earth:1111/Service1和
http://Earth:1111/Service2https://stackoverflow.com/questions/8328552
复制相似问题