我无法使用 VS2010 中提供的 Wcf 测试客户端来测试 WCF 数据服务。常规服务工作正常,但对于数据服务,我在尝试调用测试客户端中的 url 时收到此错误:
错误:无法从 http://localhost:31745/MyWcfDataService.svc 获取元数据 如果这是您有权访问的 Windows (R) Communication Foundation 服务,请检查您是否已在指定地址启用元数据发布。有关启用元数据发布的帮助,请参阅 MSDN 文档,网址为 http://go .microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange 错误 URI:http:// localhost:31745/MyWcfDataService.svc 元数据包含无法解析的引用:“http://localhost:31745/MyWcfDataService.svc”。远程服务器返回意外响应:(405) 不允许方法。远程服务器返回错误:(405) 方法不允许。HTTP GET 错误 URI:http://localhost:31745/ MyWcfDataService.svc url 处的文档 http://localhost:31745/MyWcfDataService.svc/ 未被识别为已知文档类型。来自每个已知类型的错误消息可能会帮助您解决问题:- 来自“XML 架构”的报告是“W3C XML 架构的根元素应该是,其命名空间应该是” http://www.w3.org/2001/XMLSchema'.'.- 来自“DISCO 文档”的报告是“URL 找不到http://localhost:31745/MyWcfDataService.svc/。'。 - 无法识别文档格式。- “WSDL 文档”的报告是“XML 文档 (2, 2) 中存在错误。”。 - 没有预料到。
数据服务运行良好,我可以在浏览器中查看相关 svc 文件并查看 wsdl。
wcf 测试客户端不是旨在测试 WCF 数据服务吗?如果可以使用,那么我该怎么做呢?我需要做任何修改吗?
谢谢..
I am unable to test a WCF Data service using the Wcf test client provided in VS2010. A regular service works fine but then for a data service I get this error when trying to call the url in the test client:
Error: Cannot obtain Metadata from http://localhost:31745/MyWcfDataService.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:31745/MyWcfDataService.svc Metadata contains a reference that cannot be resolved: 'http://localhost:31745/MyWcfDataService.svc'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed.HTTP GET Error URI: http://localhost:31745/MyWcfDataService.svc The document at the url http://localhost:31745/MyWcfDataService.svc/ was not recognized as a known document type.The error message from each known type may help you fix the problem:- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.- Report from 'DISCO Document' is 'Discovery document at the URL http://localhost:31745/MyWcfDataService.svc/ could not be found.'. - The document format is not recognized.- Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'. - was not expected.
The data service is running fine and I am able to do a View in browser to the svc file in question and see the wsdl.
Was wcf test client not meant to test WCF Data services? If it can be used, then how do I go about doing it? Do I need to make any modifications?
Thanks..
发布评论
评论(2)
WcfTestClient 仅适用于SOAP 绑定,例如
basicHttpBinding
、wsHttpBinding
、netTcpBinding
。它不支持基于 REST 的 WCF 服务。
做什么的??您可以使用您最喜欢的浏览器测试基于 REST 的服务 - 无需特殊的测试客户端!如果您需要执行
POST
或PUT
等 HTML 请求,您应该查看 提琴手The WcfTestClient only works with SOAP bindings, e.g.
basicHttpBinding
,wsHttpBinding
,netTcpBinding
.It does not support REST based WCF services.
What for?? You can test your REST based services using your favorite browser - no special test client needed! If you need to carry out HTML requests like a
POST
orPUT
, you should check out Fiddler我的回答可能有点晚了,但您可以使用 LINQPad 测试您的 WCF 数据服务 (http://www.linqpad.net< /a>) 支持 OData / WCF 数据服务。
My answer might be a bit late, but you could test your WCF data service with LINQPad (http://www.linqpad.net) which supports OData / WCF Data Services.