【发布时间】:2012-12-03 03:44:04
【问题描述】:
我正在尝试设置一个返回 JSON 对象的 Web 服务,并且我正在关注这个 tutorial 但是当我尝试运行它时,我收到了这个错误
错误:无法从
http://localhost:10995/Service1.svc获取元数据 如果这是您使用的 Windows (R) Communication Foundation 服务 有访问权限,请检查您是否已在以下位置启用元数据发布 指定的地址。如需帮助启用元数据发布,请 请参阅 MSDN 文档 http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata交流 错误 URI:http://localhost:10995/Service1.svc元数据包含 无法解析的引用: '本地主机:10995/Service1.svc'。远程服务器返回 意外响应:(405) 方法不允许。远程服务器 返回错误:(405)方法不允许。HTTP GET错误URI:http://localhost:10995/Service1.svc下载时出错http://localhost:10995/Service1.svc。 HTTP 请求失败 状态 404:未找到。
所以我尝试查找这意味着什么,并通过这些链接尝试修复它
WCF - Error: Cannot obtain Metadata
Error: Cannot obtain Metadata from WCF service
WCF Test Client cannot add service, cannot obtain metadata
但他们都没有解决问题。这是我第一次尝试做任何类型的网络服务,而且我今天开始研究,所以显然我对这一切都是新手。
这个错误是什么意思,我该如何修复它以便我可以测试它?
<system.serviceModel>
<services>
<service name="WcfService4.Service1" behaviorConfiguration="WcfService4.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="../Service1.svc"
binding="webHttpBinding"
contract="WcfService4.IService1"
behaviorConfiguration="webBehaviour" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService4.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="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>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
【问题讨论】:
-
正确检查端点地址、行为配置和合约名称。
-
所以没有赞成的答案或绿色勾号..知道什么可以解决这个问题吗?
标签: c# wcf web-services