我建立了一個WCF REST Web服務(WCF服務應用程序),當我與Visual Studio 2012調試,它會旋轉起來WCF測試客戶端應用程序,並嘗試添加我的網站服務。我收到以下錯誤:VS2012 WCF REST服務 - 錯誤:無法獲取元數據
Error: Cannot obtain Metadata from http://localhost:50925/Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:50925/Service1.svc Metadata contains a reference that cannot be resolved: 'http://localhost:50925/Service1.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service
我訪問上面鏈接的MSDN文檔,我相信我已正確設置我的web.config。
Web.config文件:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="Service1Behavior">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"> </endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我還是繼續收到同樣的錯誤消息。我是新來的WCF/VS 2012和.NET 4.0,但我在VS2008的.Net 2.0很流暢。