WCF服务主机找不到任何服务元数据。请检查元数据是否已启用
我的App.config文件是WCF服务主机找不到任何服务元数据。请检查元数据是否已启用,wcf,wcf-data-services,wcf-ria-services,wcf-binding,wcf-security,Wcf,Wcf Data Services,Wcf Ria Services,Wcf Binding,Wcf Security,我的App.config文件是 <?xml version="1.0"?> <configuration> <system.serviceModel> <services> <service name="WcfJsonRestService.Service1"> <endpoint address="http://localhost:8733/service1"
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="WcfJsonRestService.Service1">
<endpoint address="http://localhost:8733/service1"
binding="webHttpBinding"
contract="WcfJsonRestService.IService1"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
起初,这是一个问题
WCF服务主机配置-请尝试将HTTP端口更改为8733
因此,我在CMD中执行了以下代码
netsh http add urlacl url=http://+:8733/ user=WORK\Clara
执行此代码后,我面临如下新错误
我如何解决这个问题
我也尝试过更新App.Config,正如下面的链接所说,但是在我遇到另一个错误之后
您缺少服务元数据行为配置。请添加以下配置:
<configuration>
<system.serviceModel>
<services>
<service name="WcfJsonRestService.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733"/>
</baseAddresses>
</host>
<endpoint address="service1"
binding="webHttpBinding"
contract="WcfJsonRestService.IService1"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled ="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
您提到的链接保存了您的解决方案,您在更新网络配置时遇到了什么错误?如果在IIS上,请确保您正在编辑您的Web.config(而不是App.config)。@EzLo wenconfig不在那里,我有App.config,并且我正在本地运行,即visual Studio。我添加了thsi行,但由于ServiceMetadataBehavior的HttpGetEnabled属性设置为true,并且HttpGetUrl属性是一个相对地址,因此出现了错误,但是没有http基址。提供http基址或将HttpGetUrl设置为绝对地址。在System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(ServiceDescription说明,ServiceHostBase主机,ServiceMetadataExtension mex)@MiteshJain:我已经更新了我的答案。您需要添加基址。感谢它的工作,因为我是wcf的新手,我不知道要添加什么:-)
<configuration>
<system.serviceModel>
<services>
<service name="WcfJsonRestService.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733"/>
</baseAddresses>
</host>
<endpoint address="service1"
binding="webHttpBinding"
contract="WcfJsonRestService.IService1"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled ="true"/>
</behavior>
</serviceBehaviors>
</behaviors>