【问题标题】:WCF Service client problemWCF服务客户端问题
【发布时间】:2011-06-14 02:41:28
【问题描述】:

我正在尝试为我在 IIS 5.1 上托管的 WCF 服务创建一个客户端。我遇到了一个奇怪的问题:我可以通过浏览器访问该服务,我看到“你已经创建了一个服务”页面,但每当我尝试运行 svcutil 时(如同一页面所建议的那样)

svcutil.exe http://my.host.name/SampleService/SampleService.svc?wsdl

我收到以下错误:

Error: Cannot obtain Metadata from http://localhost.ms.com/SampleService/SampleS
ervice.svc?wsdl

If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess.  For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.


WS-Metadata Exchange Error
URI: http://localhost.ms.com/SampleService/SampleService.svc?wsdl

Metadata contains a reference that cannot be resolved: 'http://localhost.ms.
com/SampleService/SampleService.svc?wsdl'.

The HTTP request is unauthorized with client authentication scheme 'Anonymou
s'. The authentication header received from the server was 'Negotiate'.

The remote server returned an error: (401) Unauthorized.


HTTP GET Error
URI: http://localhost.ms.com/SampleService/SampleService.svc?wsdl

There was an error downloading 'http://localhost.ms.com/SampleService/Sample
Service.svc?wsdl'.

The request failed with an empty response.

If you would like more help, type "svcutil /?"

什么可能导致这个问题?

编辑:这可能是 IIS 本身的问题吗?例如,错误地设置了权限?

编辑:这是我的 web.config:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="Basic">
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
    </bindings>

    <services>
      <service name="DummyService2.SampleService"
           behaviorConfiguration="DummyService2.SampleServiceBehavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="basicHttpBinding" contract="DummyService2.ISampleService"
              bindingConfiguration="Basic" />
        <endpoint address="mex" binding="basicHttpBinding" contract="IMetadataExchange"
              bindingConfiguration="Basic" />
      </service>
    </services>


    <behaviors>
      <serviceBehaviors>
        <behavior name="DummyService2.SampleServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

【问题讨论】:

  • 请发布您的 web.config(或 app.config)文件。

标签: wcf iis svcutil.exe


【解决方案1】:

我认为这是相关的错误:

HTTP 请求未经客户端身份验证方案“匿名”授权。 从服务器收到的身份验证标头是“协商”。

Web 服务密码是否受到保护或使用集成的 Windows 身份验证?如果我没记错的话,svcutil 无法通过集成身份验证登录到 Web 服务。当您使用浏览器时,它工作得很好,因为它在后台处理 Intranet 环境的身份验证。

一种选择是手动下载并保存 wsdl,然后指向 svcutil 以使用下载的 wsdl 文件来生成类。您可能还必须下载一些 wsdl 引用的文件并编辑这些引用。

【讨论】:

  • 在 IISManager 中,在 -> Properties->DirectorySecurity 我检查了匿名访问,并且在那里指定的帐户可以访问我的 WINDOWS\Temp、WINDOWS\Microsoft.NET\Framework\ 文件夹和我的项目源文件夹。我错过了什么吗?
猜你喜欢
  • 1970-01-01
  • 2011-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多