使用 WCFTestClient 测试简单的 WCF Web 服务时出现 WCF 错误
当我尝试使用“wcftestclient”测试 AutoLotWCFService 时,出现以下错误。 我究竟做错了什么? 任何见解都会有所帮助。 这是一个简单的 Web 服务,具有带有接口契约的 wshttpbind 和服务中的实现。 下面是很长的错误消息: 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.'.
When I try to test the AutoLotWCFService using "wcftestclient", I get the following error. What am I doing wrong? Any insight will help. This is a simple Web Service that has wshttpbinding with interface contract and the implementation in the service. Here is the long error message: The Web.Config file has 2 endpoints - one for Web Service itself and other for metaDataExchange. Its all pretty much default stuff. I can include the code if needed - it seems I cannot attach files here.
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.'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我最近在尝试在 IIS7 下的 Windows Vista 笔记本电脑上托管 WCF 时遇到了这个问题。
我首先收到以下错误:“HTTP 错误 404.3 - 未找到”,建议的解决方案之一是“确保映射当前页面的预期处理程序”。
因此,我手动为 .svc 文件添加了一个处理程序,并将其定义为 DiscoveryRequestHandler,认为这可能会有所帮助。 这导致了您上面描述的问题。
实际的解决方案是删除我添加的处理程序,并运行以下命令:
这解决了我的问题,并且服务工作正常。 我希望这可能有助于阐明您的问题。 我不能确定,但这可能是因为我在开发笔记本电脑上安装各种软件包的顺序。
I recently had this problem whilst trying to host WCF on my Windows Vista Laptop under IIS7.
I first recieved the following error : "HTTP Error 404.3 - Not Found" and one of the resolutions suggested was to "Ensure that the expected handler for the current page is mapped."
So I added a handler for the .svc file manually and defined it as a DiscoveryRequestHandler, thinking that this might help. This caused the problem you described above.
The actual resolution was to delete the handler I had added, and to run the following commands:
This resolved my issue and the service is working fine. I hope this might help shed some light on your problem. I can't be certain but this is probably because of the order in which I've installed the various packages on my dev laptop.
如果安装组件不起作用,请尝试修复,这将卸载然后安装。
If installing compenonts doesnt work try a repair, this uninstalls and then installs.
您需要确保服务行为配置启用具有 httpGetEnabled="true" 的元数据标记。
此外,请确保您的服务引用该行为。
you need to make sure that the service behaviour configuration enables has a metadata tag with httpGetEnabled="true"
In addition, make sure your service references that behavior.
谢谢; 不管你信不信,当我用aspnet-regiis在IIS中重新注册ASPNET时,至少通过wcftestclient加载服务的问题得到了解决。
下一个问题是能够通过 wcftestclient 调用服务公开的方法。 我必须处理哪些安全问题? 我必须使用 Windows 身份验证启用匿名登录。 并且调用仍然生成指向与访问冲突相关的异常。 在搜索某些内容时,需要安装证书才能调用。如果可能,请赐教。
Thanks; believe it or not the problem of at least loading the service through wcftestclient was solved when I re-registered the ASPNET in IIS with aspnet-regiis.
The next problem is to be able to invoke the methods exposed by the service through wcftestclient. What are the security issues that I have to deal with? I had to enable Anonymous login with windows auth. and still the invoke generated exceptions that pointed to something related to access violation. On searching some things point to installing certificates to be able to invoke.. Please enlighten if possible.
尝试检查服务标记中的服务(名称)(右键单击 servicename.svc)是否与 web.config 文件中的服务(名称)匹配。
干杯!
Try checking if service(name) in the Service Markup (right click on servicename.svc) matches the service(name) in your web.config file.
Cheers!