使用 WCFTestClient 测试简单 WCF Web 服务的 WCF 错误 [英] WCF Errors using WCFTestClient to test a simple WCF Web Service

查看:41
本文介绍了使用 WCFTestClient 测试简单 WCF Web 服务的 WCF 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.'.

<小时>

推荐答案

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

I recently had this problem whilst trying to host WCF on my Windows Vista Laptop under IIS7.

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

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."

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

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:

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

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

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.

这篇关于使用 WCFTestClient 测试简单 WCF Web 服务的 WCF 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆