我试图通过IIS和IIS中的http和net.tcp绑定公开WCF服务。 似乎一切都按预期方式工作时,我只指定的net.tcp绑定,或只是HTTP绑定,但是当我同时添加wcftestclient程序和所有其他服务代理生成失败:IIS中的多个WCF服务端点中断wcftestclient
Error: Cannot obtain Metadata from net.tcp://host/application/service.svc ... Metadata Exchange Error URI: net.tcp://host/application/service.svc Metadata contains a reference that cannot be resolved: 'net.tcp://host/application/service.svc '. There was > no endpoint listening at net.tcp://host/application/service.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
我的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一个仍然可用。有什么想法吗?
编辑: 基于马克的建议下,我改变了相关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" />
预期其作品!
谢谢您的回答。是的,'net.tcp'是可用的(没有basicHttpBinding它实际工作)。我相信当在IIS中托管时,web.config中的''被忽略,并且可悲的是,指定完整端点地址的建议似乎没有任何区别。 –
2011-12-21 18:36:33
你其实是对的,IIS需要完整指定net.tcp端点地址。它应该指向相应的'.svc'! – 2011-12-21 18:44:36
@FrankRazenberg:好的;谢谢你的提醒。我从来没有在IIS/WAS内托管过net.tcp,所以这是未来的事情 - 谢谢! – 2011-12-21 20:35:29