2011-04-05 159 views
1

閱讀「WCF4.0中的新功能」教程。第一個練習是建立一個沒有任何配置的服務。然後,您將一些配置設置到位以提供服務元數據。簡單的東西。WCF端點配置

我現在試圖做的是擴大配置,露出一個不同的端口在同一個服務合同 - 在這種情況下http://localhost:9001/test

這是我的配置...

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="WCF4Configuration.EchoServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="WCF4Configuration.EchoServiceBehavior" name="WCF4Configuration.EchoService"> 
      <endpoint address="" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
      </endpoint>        
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      <endpoint address="http://localhost:9001/test" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService"/> 
     </service> 
    </services> 
</system.serviceModel> 

然而我試圖連接到這個我得到的消息,機器積極拒絕連接。爲什麼這不起作用?我可以在wcftestclient中使用什麼地址來顯示服務?

回答

0

嘗試:

<services> 
     <service behaviorConfiguration="WCF4Configuration.EchoServiceBehavior" name="WCF4Configuration.EchoService"> 
      <endpoint address="" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
      </endpoint>        
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      <endpoint address="" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService"> 
      <host> 
      <baseAddresses> 
       <add baseAddress="http://localhost:9001/test/" /> 
      </baseAddresses> 
      </endpoint> 
     </service> 
</services>