WCFTestClient The HTTP request is unauthorized with client authentication scheme 'Anonymous'

前端 未结 9 1449
囚心锁ツ
囚心锁ツ 2020-12-05 01:34

I\'ve created one WCF service and deployed it on Server. When I browse this service it gives me positive response with ?wsdl URL. Now I\'m trying to test the service through

相关标签:
9条回答
  • 2020-12-05 01:51

    I have a similar issue, have you tried:

    proxy.ClientCredentials.Windows.AllowedImpersonationLevel =   
              System.Security.Principal.TokenImpersonationLevel.Impersonation;
    
    0 讨论(0)
  • 2020-12-05 01:51

    Just got this problem on a development machine (production works just fine). I modify my config in IIS to allow anonymous access and put my name and password as credential.

    Not the best way I am sure but it works for testing purposes.

    0 讨论(0)
  • 2020-12-05 02:01

    Try providing username and password in your client like below

    client.ClientCredentials.UserName.UserName = @"Domain\username"; client.ClientCredentials.UserName.Password = "password";

    0 讨论(0)
  • 2020-12-05 02:04

    Another possible solution to this error that I found. Might not have answered OP's exact question but may help others who stumble across this error message.

    I was creating my Client in code using WebHttpBinding, in order to replicate the following line:

    <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
    </security>
    

    I had to do:

    var binding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
                    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Windows;
    

    as well as setting proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

    0 讨论(0)
  • 2020-12-05 02:06

    I had the same error today, after deploying our service calling an external service to the staging environment in azure. Local the service called the external service without errors, but after deployment it didn't.

    In the end it turned out to be that the external service has a IP validation. The new environment in Azure has another IP and it was rejected.

    So if you ever get this error calling external services

    It might be an IP restriction.

    0 讨论(0)
  • 2020-12-05 02:07

    I see this isn't answered yet, this is an exact quote from here:

    WSHttpBinding will try and perform an internal negotiate at the SSP layer. In order for this to be successful, you will need to allow anonymous in IIS for the VDir. WCF will then by default perfrom an SPNEGO for window credentials. Allowing anonymous at IIS layer is not allowing anyone in, it is deferring to the WCF stack.

    I found this via: http://fczaja.blogspot.com/2009/10/http-request-is-unauthorized-with.html

    After googling: http://www.google.tt/#hl=en&source=hp&q=+The+HTTP+request+is+unauthorized+with+client+authentication+scheme+%27Anonymous

    0 讨论(0)
提交回复
热议问题