重现问题:http请求被禁止使用客户端身份验证方案'anonymous'

时间:2015-04-29 14:02:03

标签: c# wcf http wcf-binding wcf-security

我想重新制作wcf问题: http请求被禁止使用客户端身份验证方案'anonymous'

我们在产品中使用wcf服务,并且我们已将wcf服务托管为Windows服务(自托管服务),并且这个wcf服务正由一个小的 Windows客户端应用程序使用即可。

在我们的环境中,事情正常。但是,我们的一位客户报告说他们从远程客户端连接客户端应用时收到错误“ http请求被禁止使用客户端身份验证方案'匿名'”机。

在这里,我的问题是,任何人都可以帮助我在我们的环境中重新生成这个问题,以便我们能够提供完美的解决方案。

ServiceApp.config

<bindings>
      <wsHttpBinding>
        <binding name="MyBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="100" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
          <reliableSession inactivityTimeout="24.00:00:00" />
          <security mode="None">
            <message clientCredentialType="None" />
          </security>

        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyBehaviour" name="WcfServer.CalculatorService">
        <endpoint address="http://localhost:7000/Test" behaviorConfiguration="MyEndPointBehavior"
          binding="wsHttpBinding"  bindingConfiguration="MyBinding"
          name="EndPt_Service" contract="WcfServer.ICalculator"/>
      </service>
    </services>

clientapp.config

<bindings>
      <wsHttpBinding>
        <binding name="CalBinding" maxBufferPoolSize="2147483647"  maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="100" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
          <reliableSession inactivityTimeout="24.00:00:00" />
          <security mode="None">
            <message clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://RemoteServerName:7000/Test" behaviorConfiguration="CalEndPointBehavior"
        binding="wsHttpBinding" contract="WcfServer.ICalculator"
         name="EndPt_Calc" bindingConfiguration="CalBinding"/>
    </client>

1 个答案:

答案 0 :(得分:1)

我在msdn论坛找到了这个,希望这可以帮到你:

由于您已为WsHttpBinding指定了Security Mode = none,因此当它向WCF服务发出请求时,服务将尝试使用Aninymous凭据对客户端进行身份验证,但是如果是不同的域,则无法使用,因此请尝试使用X509证书。

因此,尝试在两个不同的域之间建立连接。