【发布时间】:2012-01-25 12:34:24
【问题描述】:
我正在尝试通过 IIS 中的 http 和 net.tcp 绑定公开 WCF 服务。 当我只指定 net.tcp 绑定或只指定 http 绑定时,一切似乎都按预期工作,但是当我添加 wcftestclient 程序和所有其他服务代理生成器时都失败了:
错误:无法从 net.tcp://host/application/service.svc 获取元数据 ... 元数据交换错误 URI:net.tcp://host/application/service.svc 元数据包含无法解析的引用:“net.tcp://host/application/service.svc”。 > 在 net.tcp://host/application/service.svc 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。
我的 web.config 如下所示:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="MyServiceBehavior">
<endpoint address="mex-http" binding="mexHttpBinding" name="mex-http" contract="IMetadataExchange" />
<endpoint address="service-http" binding="basicHttpBinding" name="db-http" contract="IMyService" />
<endpoint address="mex-tcp" binding="mexTcpBinding" name="mex-http" contract="IMetadataExchange" />
<endpoint address="service-tcp" binding="netTcpBinding" name="db-http" contract="IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
所以,如果我删除 mex-http 和 db-http 端点,一切都很好。如果我不这样做,则可以通过 http 访问该服务,但不能通过 tcp 访问该服务。如果我删除 tcp 端点,当然 http 端点仍然可用。有什么想法吗?
编辑:
根据 Marc 的建议,我将相关的 net.tcp 端点更改为阅读
<endpoint name="mex-http" address="net.tcp://localhost/myservice/MyService.svc/mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<endpoint name="db-http" address="net.tcp://localhost/myservice/MyService.svc" binding="netTcpBinding" contract="IMyService" />
按预期工作!
【问题讨论】:
标签: wcf iis web-config nettcpbinding