我試圖通過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