WCF错误:URI的注册已存在
下面是我的WCF服务配置。我使用2个ServiceHost来承载2种服务类型。它们使用相同的基址,但它们的端点使用不同的相对地址 但我犯了这个错误,为什么 无法启动服务。System.InvalidOperationException:位于'http://earth:1111/'with contract'“IHTTPGethelpageandMetadataContract”无法打开其IChannelListener。-->System.InvalidOperationException:URI的注册已存在http://earth:1111/“。WCF错误:URI的注册已存在,wcf,Wcf,下面是我的WCF服务配置。我使用2个ServiceHost来承载2种服务类型。它们使用相同的基址,但它们的端点使用不同的相对地址 但我犯了这个错误,为什么 无法启动服务。System.InvalidOperationException:位于'http://earth:1111/'with contract'“IHTTPGethelpageandMetadataContract”无法打开其IChannelListener。-->System.InvalidOperationException:UR
<?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>
您是否尝试删除其中一个服务块并将端点合并为一个
我看不出你为什么要把他们分开
确保baseaddress+端点地址是唯一的 不能用相同的基址承载两个服务
您需要在不同的端口或地址上承载另一个
差不多
http://Earth:1111/Service1
及
我真的不知道为什么会这样,但一个解决方案是让服务没有基址,并为端点指定完整地址。这不会改变不同端点的地址,也不会改变地址的唯一性。我在MSDN上找不到任何相关的参考资料
根据我自己的经验,问题出现在http上,而不是net.tcp上。我没有使用服务元数据。我认为“IHttpGetHelpPageAndMetadataContract”与元数据有关,但没有办法禁用它。可以使用相同的基址承载多个服务。将HttpHelpPageEnabled
和HttpsHelpPageEnabled
的all
ServiceDebugBehavior
s属性设置为false
,然后它就可以工作了
Atention:默认情况下,主机的行为描述集合中始终会注册一个
ServiceDebugBehavior
,即使它没有明确指定(我仅使用programatic配置和ServiceHost
类进行了尝试,而不是通过XML配置)。因此,您应该添加一个显式的ServiceDebugBehavior
,并设置所提到的属性。IncludeExceptionDetailInFaults
属性可以是true
如果您不小心启动了同一个服务两次,而不是启动了两个不同的服务,那么也会出现此错误。似乎WCF端点的设计有些混乱。
http://Earth:1111/Service1
http://Earth:1111/Service2