嗨,我正在使用WCF,MVC4和AngularJS开发小型应用程序。我指的是url
https://code.msdn.microsoft.com/angularjs-shopping-cart-8d4dde90#content
当我尝试在我的MVC应用程序中添加服务参考时,我要低于错误
Metadata publishing for this service is currently disabled.
我在下面提供了访问服务。
http://localhost:55835/Service1.svc
当我尝试时,我会遇到错误。我无法在应用程序中添加服务参考。我不担心我的web.config文件。这是我的web.config文件。
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp helpEnabled="True"/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
有人可以告诉我我缺少配置文件中的任何内容吗?
预先感谢您。
此问题正在显示,因为您不启用getadata.metadata(服务代码的WSDL文档)是必不可少的,因为您的客户端将根据您的元数据(WSDL代码)生成代理类(WSDL代码)。如果您不启用元数据,那么您的客户将永远不会知道如何在其代理类中实现相同类型的代码。可以通过将httpgetEnabled设置为true。
在</endpointBehaviors>
标签之后,在ServiceBehavior标签下添加此行代码。(请不再包含<behaviour>
标签)
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpGetUrl="true"/>
</behavior>
</serviceBehaviors>
</behaviors>