我想使用netTcpBinding和basicHttpBinding提供相同的接口。我也想爲兩個端點提供wsdl。當我訪問http://localhost:9876/TestService/
時,我得到的mex端點具有Tcp端點的信息http://localhost:9876/TestService/?wsdl
,但地址http://localhost:9876/TestService/ws
沒有響應,我不明白爲什麼。我有基地址和相對地址。有人能幫我指出缺少的東西嗎?現在,我只是試圖讓TestImplementation服務工作,並且我沒有與MessaginImplementation服務混淆。帶有basicHttpBinding和netTcpBinding的WCF服務;無法訪問HTTP端點
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SimpleBinding" />
</basicHttpBinding>
<netTcpBinding>
<binding name="DefaultTCPBinding" transactionFlow="true" />
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
httpGetBindingConfiguration="" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetadataBehavior" name="CompanyX.AppServer.Implementation.TestImplementation">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="DefaultTCPBinding"
name="TestTCPEndpoint" contract="CompanyX.AppServer.Interfaces.ITest" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="TestMex" contract="IMetadataExchange" />
<endpoint address="/ws" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
name="Test" contract="CompanyX.AppServer.Interfaces.ITest" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9878/TestService" />
<add baseAddress="http://localhost:9876/TestService/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="MetadataBehavior" name="CompanyX.AppServer.Implementation.MessaginImplementation">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="DefaultTCPBinding"
name="MessagingTCPEndpoint" contract="CompanyX.AppServer.Interfaces.IMessaging" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="MessagingMex" contract="CompanyX.AppServer.Interfaces.IMessaging" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9878/MessagingService" />
<add baseAddress="http://localhost:9876/MessagingService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
我試過沒有它,但我沒有得到答案。我從這個微軟鏈接得到了這個:http://msdn.microsoft.com/en-us/library/ms733749.aspx – Pascal 2010-12-10 21:39:09
@Pascal:不知道你的基地址中的尾部斜線是否會導致一個問題:' ' - 嘗試沒有它 - 任何改變? –
2010-12-10 22:20:31
抱歉浪費你的時間。這是一個新秀WCF的錯誤。我發佈了下面的答案,以供將來參考任何與我未來相同的疑問。謝謝你太多了! – Pascal 2010-12-11 02:21:30