【问题标题】:The HTTP request was forbidden with client authentication scheme 'Anonymous'. - Wcf test client客户端身份验证方案“匿名”禁止 HTTP 请求。 - Wcf 测试客户端
【发布时间】:2020-07-20 22:47:34
【问题描述】:

我已经使用 basichttpbinding 开发了一个 wcf 服务。我已经在 Web 服务器上托管了该服务。有一个负载均衡器通过 https url 公开此服务。当我尝试访问通过负载均衡器公开的端点地址时,它会在 wcf 测试客户端中引发错误 - “客户端身份验证方案‘匿名’禁止 HTTP 请求。” 下面是 web.config 的配置:

<?xml version="1.0"?>
<configuration>     
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="testServiceBehavior">
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false"
            serviceAuthorizationAuditLevel="SuccessOrFailure" messageAuthenticationAuditLevel="SuccessOrFailure" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="testServiceBehavior" name="TestService">
        <endpoint address=""  binding="basicHttpBinding"
           contract="TestService.IService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

【问题讨论】:

    标签: wcf service


    【解决方案1】:

    确保在 IIS 中启用匿名身份验证:

    如果该值设置为Disable,客户端调用时需要提供Windows身份信息。

    【讨论】:

      猜你喜欢
      • 2016-02-04
      • 2011-03-01
      • 2014-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-05
      • 2015-07-08
      相关资源
      最近更新 更多