WCF error: The caller was not authenticated by the service

前端 未结 10 483
野性不改
野性不改 2020-12-01 03:53

I am trying to access my WCF service on a server from my client console application for testing. I am getting the following error:

The caller was no

相关标签:
10条回答
  • 2020-12-01 04:08

    if needed to specify domain(which authecticates username and password that client uses) in webconfig you can put this in system.serviceModel services service section:

    <identity>          
    <servicePrincipalName value="example.com" />
    </identity>
    

    and in client specify domain and username and password:

     client.ClientCredentials.Windows.ClientCredential.Domain = "example.com";
     client.ClientCredentials.Windows.ClientCredential.UserName = "UserName ";
     client.ClientCredentials.Windows.ClientCredential.Password = "Password";
    
    0 讨论(0)
  • 2020-12-01 04:13

    I got it.

    If you want to use wshttpbinding, u need to add windows credentials as below.

    svc.ClientCredentials.Windows.ClientCredential.UserName = "abc";
    svc.ClientCredentials.Windows.ClientCredential.Password = "xxx";
    

    thanks

    0 讨论(0)
  • 2020-12-01 04:17

    If you use basicHttpBinding, configure the endpoint security to "None" and transport clientCredintialType to "None."

    <bindings>
        <basicHttpBinding>
            <binding name="MyBasicHttpBinding">
                <security mode="None">
                    <transport clientCredentialType="None" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="MyServiceBehavior" name="MyService">
            <endpoint 
                binding="basicHttpBinding" 
                bindingConfiguration="MyBasicHttpBinding"
                name="basicEndPoint"    
                contract="IMyService" 
            />
    </service>
    

    Also, make sure the directory Authentication Methods in IIS to Enable Anonymous access

    0 讨论(0)
  • 2020-12-01 04:22

    This can be caused if the client is in a different domain than the server.

    I encountered this when testing one of my applications from my PC(client) to my (cloud) testing server and the simplest solution i could think of was setting up a vpn.

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