【问题标题】:WCF Errors using WCFTestClient to test a simple WCF Web Service使用 WCFTestClient 测试简单 WCF Web 服务的 WCF 错误
【发布时间】:2010-09-16 09:48:51
【问题描述】:

当我尝试使用“wcftestclient”测试 AutoLotWCFService 时,我收到以下错误。我究竟做错了什么?任何见解都会有所帮助。这是一个简单的 Web 服务,它具有 wshttpbinding 和接口契约以及服务中的实现。这是长错误消息: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.'.

【问题讨论】:

  • 您能否包含与服务相关的配置部分?没有这个就很难说到底发生了什么。
  • 服务合同(以及任何使用的数据合同)也会有所帮助。
  • 在指定的 下将此添加到您的服务器 Web 配置,然后将提供真正的错误:

标签: wcf using wcftestclient


【解决方案1】:

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

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

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

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

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

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

【讨论】:

  • 太棒了!这就像一个魅力。有一个 404.17 问题,这解决了它。
  • 这也解决了我的“方法不允许”错误。该服务可以在 Visual Studio 的内置 Web 服务器上运行,但不能在 localhost 上的 iis 上运行。现在它也适用于 iis。
【解决方案2】:

如果安装组件不起作用尝试修复,这将卸载然后安装。

"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r

【讨论】:

    【解决方案3】:

    您需要确保启用的服务行为配置具有带有 httpGetEnabled="true" 的元数据标记

    <serviceBehaviors>
      <behavior name="serviceBehavior">
        <serviceMetadata httpGetEnabled="true">
      &lt/behavior>
    </serviceBehaviors>
    

    此外,请确保您的服务引用该行为。

    
    <service name="blah" behaviorConfiguration="serviceBehavior">
    

    【讨论】:

      【解决方案4】:

      谢谢;信不信由你,当我使用 aspnet-regiis 在 IIS 中重新注册 ASPNET 时,至少通过 wcftestclient 加载服务的问题得到了解决。

      下一个问题是能够通过 wcftestclient 调用服务公开的方法。我必须处理哪些安全问题?我必须使用 Windows auth 启用匿名登录。并且仍然调用生成的异常指向与访问冲突相关的内容。在搜索某些东西时,指向安装证书以便能够调用..如果可能,请赐教。

      【讨论】:

        【解决方案5】:

        尝试检查服务标记中的 service(name)(右键单击 servicename.svc)是否与 web.config 文件中的 service(name) 匹配。

        干杯!

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-02-15
          • 1970-01-01
          • 1970-01-01
          • 2011-11-03
          • 2013-01-08
          • 2014-01-08
          • 1970-01-01
          相关资源
          最近更新 更多