I'm trying to call a method for a web service we use. I keep getting this error
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate, NTLM'.
The reference file shows that the class is a sub class of ClientBase.
I'm able to see the Web.Config file but not manipulate it. This is what it shows for binding.
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingWinAuthConf" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2000000000" maxArrayLength="2000000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webHttpBindingConf">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
<customBinding>
<binding name="binaryHttpBindingSecuredFalse" maxSessionSize="2000000000">
<binaryMessageEncoding>
<readerQuotas maxDepth="32" maxStringContentLength="2000000000" maxArrayLength="2000000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpTransport maxReceivedMessageSize="2000000000" transferMode="StreamedResponse" authenticationScheme="Negotiate" />
</binding>
<binding name="binaryHttpBindingSecuredTrue" maxSessionSize="2000000000">
<binaryMessageEncoding>
<readerQuotas maxDepth="32" maxStringContentLength="2000000000" maxArrayLength="2000000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpsTransport maxReceivedMessageSize="2000000000" transferMode="StreamedResponse" authenticationScheme="Negotiate" />
</binding>
<binding name="binaryHttpBindingSecured" maxSessionSize="2000000000">
<binaryMessageEncoding>
<readerQuotas maxDepth="32" maxStringContentLength="2000000000" maxArrayLength="2000000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpsTransport maxReceivedMessageSize="2000000000" transferMode="StreamedResponse" authenticationScheme="Negotiate" />
</binding>
<binding name="binaryHttpBinding" maxSessionSize="2000000000">
<binaryMessageEncoding>
<readerQuotas maxDepth="32" maxStringContentLength="2000000000" maxArrayLength="2000000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpTransport maxReceivedMessageSize="2000000000" transferMode="StreamedResponse" authenticationScheme="Negotiate" />
</binding>
</customBinding>
</bindings>
I've tried the code below to authorize my call
BasicHttpBinding bind = new BasicHttpBinding();
bind.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
bind.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
EndpointAddress endpoint = new EndpointAddress("http://uri_to_service/transactionservices.asmx");
Before the update I would use this line of code and it worked as it should
TS.Credentials = System.Net.CredentialCache.DefaultCredentials;
What am I doing wrong?
UPDATE
I've also tried this and had no luck...
TS.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
TS.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
Some have suggested this but did not work....
TS.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
looking into the web config file I saw this so I don't it would work anyways..
<authentication mode="Windows" />
<identity impersonate="false" />
Any ideas?