2012-02-15 91 views
0

我在MS Web Developer 2010 Express中創建了WCF服務庫,其ITestSerivce是服務合同,並且遵循Web.config配置。但是我得到這個錯誤 : 錯誤:無法從http://localhost:56016/TestService.svc 獲得元數據: 我不明白爲什麼網址是http://localhost:56016其中基址是http://localhost:8001在MS Web Developer 2010 Express中構建WCF服務庫

任何人可以幫助我這個問題。

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="TestService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress ="http://localhost:8001/" /> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="wsHttpBinding" contract="ITestService"/>   
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <!--Setting httpGetEnabled you can publish the metadata --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="SampleServiceBinding"> 
      <security/> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

回答

2

上面的配置有幾個問題。

  1. 該服務元素具有不完全限定名的屬性attibute。

  2. 端點元素的合約屬性值不是完全限定名稱。

一個完全合格的名稱如下圖所示:

MyWCFService.TestService (i.e. namespace.ServiceName) 

如果您運行的是相同的卡西尼Web服務器上,然後右擊屬性和網絡選項卡下,確保「用戶視覺Studio Development Server「選項,並且未選擇」自動分配端口「選項。而是選擇「特定端口」並使用8001來匹配您的配置

+0

我沒有使用cassini並使用WCF Test Client工具。爲什麼它會顯示 http:// localhost:56016/TestService.svc。 – sameer 2012-02-15 12:43:10

+0

您的WCF服務如何託管? – Rajesh 2012-02-15 13:44:08

0

<baseAddresses>配置僅適用於self-hosted服務+應用程序,並未由IIS/WAS使用。 如果你把'了.svc您的Web服務器上/網站定義了它的網址,除非您使用的功能,如文件無激活(article here

你的IIS URL將會像

http://localhost:8001/MyApp/TestService.svc?wsdl

我不知道爲什麼WCF測試客戶端默認爲錯誤的URL - 只需輸入正確的一個,它會緩存它。

相關問題