[英]Failed to add a service Service metadata may not be accessible . Error: Cannot obtain Metadata from http://localhost:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="web">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="webHttp" bindingConfiguration="" contract="WcfService1.IService1"></endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="web">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<!--<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>-->
<!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />-->
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I am trying to add webHttpBinding
setting to webconfig but get the following error: 我正在尝试将
webHttpBinding
设置添加到webconfig,但是出现以下错误:
Failed to add a service.
添加服务失败。 Service metadata may not be accessible.
服务元数据可能无法访问。 Make sure your service is running and exposing metadata.
确保您的服务正在运行并公开元数据。
You have this problem because you have commented out serviceMetadata
element in web
behavior. 您有此问题,因为您已注释掉
web
行为中的serviceMetadata
元素。 Without it service metadata is not actually published. 没有它,服务元数据实际上不会发布。 Just uncomment it back and the problem will be fixed:
只需取消注释即可,问题将得到解决:
<behavior name="web">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.