WCF Issue-The HTTP request is unauthorized with client authentication scheme ‘Negotiate’. The authentication header received from the server was ‘NTLM’.
When calling any WCF/web services/Sharepopint services via WCF, you will normally get this error if you leave the settings as configured by the “Add Service Reference Wizard” :
“The HTTP request is unauthorized with client authentication scheme ‘Negotiate’. The authentication header received from the server was ‘NTLM’.”
You must specify a non-anonymous impersonation level for your ClientCredentials. Just specifying a username and password for your WCF Service reference’s ClientCredentials.UserName.UserName and ClientCredentials.UserName.Password is not sufficient to resolve the problem. This is utter necessary when you are calling service from different domain.
ServiceReference1.Service serviceClient = new ServiceReference1.Service();
serviceClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(“username”, “password”, “domain”);
serviceClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
When you are in same domain, don’t have to pass in the Windows.ClientCredential information. You can also set the above values in app.config configuration elements rather than code.
You can use (with descending levels of security):
<transport clientCredentialType=”Windows” />
<message clientCredentialType=”UserName” algorithmSuite=”Default” />
Now you run program and above issue is fixed.