我已经构建了一个 WCF REST Web 服务(WCF 服务应用程序),当我使用 Visual Studio 2012 进行调试时,它将启动 WCF 测试客户端应用程序并尝试添加我的 Web 服务。我收到以下错误:
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。
网络配置:
<?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。