简体   繁体   中英

Reproduce Issue: The http request was forbidden with client authentication scheme 'anonymous'

I would like to re-produce the wcf issue : The http request was forbidden with client authentication scheme 'anonymous'

We are using wcf service in our product and we have hosted the wcf service as Windows Service ( Self-Host service ) and this wcf service is being consumed by a small windows client app .

Things are working fine in our environment. But, one of our customer reported that they are receiving the error " The http request was forbidden with client authentication scheme 'anonymous' " while they connect the client app from remote client machine.

Here, my question is, can anyone help me to re-generate this issue in our environment, so that we can give perfect fix.

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>

I found this in the msdn forum, I hope this helps you:

Since you have specified Security Mode= none for WsHttpBinding, when it make request to WCF service , service will try to authenticate client using Aninymous credentials, but in case of different domains this will not work, so try to use X509 certitifates.

So try to establish a connection between two different domains.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM