2010-12-10 63 views
3

我想使用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> 

回答

1

這是我的一個菜鳥錯誤。這其實是正確的。答案在the post below。 當我打到基本的HTTP類時,我只收到來自瀏覽器的響應,但使用此wsdl,我可以連接兩個綁定。

0

我懷疑你的服務端點地址是錯誤的:

<endpoint address="/ws" binding="basicHttpBinding" bindingConfiguration="SimpleBinding" 
       name="Test" contract="CompanyX.AppServer.Interfaces.ITest" /> 

因爲它是一個相對地址(添加到您的基地址),應該只是ws - 沒有領先斜線:

<endpoint name="Test" 
      address="ws" 
      binding="basicHttpBinding" bindingConfiguration="SimpleBinding" 
      contract="CompanyX.AppServer.Interfaces.ITest" /> 

嘗試它沒有正斜槓!應該以這種方式工作。

+0

我試過沒有它,但我沒有得到答案。我從這個微軟鏈接得到了這個:http://msdn.microsoft.com/en-us/library/ms733749.aspx – Pascal 2010-12-10 21:39:09

+0

@Pascal:不知道你的基地址中的尾部斜線是否會導致一個問題:'' - 嘗試沒有它 - 任何改變? – 2010-12-10 22:20:31

+0

抱歉浪費你的時間。這是一個新秀WCF的錯誤。我發佈了下面的答案,以供將來參考任何與我未來相同的疑問。謝謝你太多了! – Pascal 2010-12-11 02:21:30

相關問題