使用 WCFTestClient 测试简单 WCF Web 服务的 WCF 错误

标签 wcf using wcftestclient

当我尝试使用“wcftestclient”测试 AutoLotWCFService 时,出现以下错误。我究竟做错了什么?任何见解都会有所帮助。这是一个简单的 Web 服务,它具有 wshttpbinding 和接口(interface)契约以及服务中的实现。这是长错误消息:Web.Config 文件有 2 个端点 - 一个用于 Web 服务本身,另一个用于 metaDataExchange。它几乎都是默认的东西。如果需要,我可以包含代码 - 似乎我无法在此处附加文件。

Error: Cannot obtain Metadata from http://localhost/AutoLotWCFService/Service.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/AutoLotWCFService/Service.svc
    Metadata contains a reference that cannot be resolved: 'http://localhost/AutoLotWCFService/Service.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/AutoLotWCFService/Service.svc
    The document at the url http://localhost/AutoLotWCFService/Service.svc was not recognized as a known document type.The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2.'.
    - Report from 'WSDL Document' is 'There is an error in XML document (1, 2).' -Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2.
    - Report from 'XML Schema' is 'Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2.'.

最佳答案

我最近在尝试在 IIS7 下的 Windows Vista 笔记本电脑上托管 WCF 时遇到了这个问题。

我首先收到以下错误:“HTTP 错误 404.3 - 未找到”,建议的解决方案之一是“确保映射当前页面的预期处理程序”。

所以我手动为 .svc 文件添加了一个处理程序,并将其定义为 DiscoveryRequestHandler,认为这可能会有所帮助。这导致了您上面描述的问题。

实际的解决方案是删除我添加的处理程序,并运行以下命令:

CD c:\windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\
ServiceModelReg -i

这解决了我的问题,服务运行良好。我希望这可能有助于阐明您的问题。我不能确定,但​​这可能是因为我在开发笔记本电脑上安装各种软件包的顺序。

关于使用 WCFTestClient 测试简单 WCF Web 服务的 WCF 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/189436/

相关文章:

wcf - 在具有消息安全性的 WCF 中使用 wsHttp 传输大量数据负载(序列化对象)

c# - WCF 服务客户端配置生成错误

c# - 使用 BasicHttpBinding 进行身份验证的 WCF 服务

wcf - 如何禁用 WCF 测试客户端 - VS 2012

wcf - 如何在 wcf rest 服务中添加全局错误处理

wcf - 基本 HTTP 绑定(bind)未正确配置

C++ 这行代码是什么意思?

c++ - "using"命名空间和声明命名空间有什么区别?

c# - 是否会在带有空对象的 using 语句中调用 Dispose()?

wcf - SoapUI wsdl wcf net.tcp 缺少导入程序