2012-10-13 90 views
0

我使用VS2010 Win 2008 R2。我創建了一個「WCF服務庫」,將它放在IIS中的虛擬目錄中,並將其轉換爲應用程序。在IIS中發佈的服務稱「此服務的元數據發佈當前已禁用」

我將svc文件放在應用程序的根目錄下,並將輸出構建路徑更改爲bin。每次嘗試URL http://localhost/test1/Service1.svc我收到錯誤「此服務的元數據發佈當前已禁用」。我也試過了URL http://localhost/test1/MEX。 Mex行爲配置正確,但出現此錯誤。

當我嘗試將服務引用添加到控制檯應用程序時,它也找不到服務的元數據。

+0

你試過找什麼?請顯示web.config的相關部分(system.serviceModel部分)。另外,'test1'目錄中的'bin'目錄是什麼?此外,檢查[這個問題](http://stackoverflow.com/questions/4917761/wcf-metadata-publishing-for-this-service-is-currently-disabled-content-type-er)或[this one]( http://stackoverflow.com/questions/6290323/solve-wcf-error-metadata-publishing-for-this-service-is-currently-disabled),因爲它們包含了很多你可以檢查的有用答案。 – CodeCaster

回答

0

你可以請你分享一下配置文件serviceBehavior部分嗎?

它應該是這樣的,以啓用元數據交換。

<serviceBehaviors> 
    <behavior name="SampleServiceBehavior"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 
</serviceBehaviors> 
0

這是配置文件:

<configuration> 
    <system.serviceModel> 
    <services> 
    <service name="WcfServiceLibrary4.Service1" behaviorConfiguration="ServiceBehavior"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost/test/"/> 
      </baseAddresses> 
     </host> 

     <endpoint address="" binding="basicHttpBinding" 
      contract="WcfServiceLibrary4.IService1"/> 

     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 

      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

我第一次啓用虛擬文件夾的匿名訪問之後,我看到了 - 錯誤「元數據發佈這項服務目前已被停用。」
我試過「http:// localhost/test/mex」,但IIS說「沒有這樣的資源」。在這裏我提到「test」而不是「test1」,因爲我更改了虛擬文件夾。 Bin文件夾在測試中,並且從項目的構建輸出設置爲Bin bin/Debug。

相關問題