We have a WCF service which is windows authenticated. Binding is configured as below.
<basicHttpBinding>
<binding textEncoding="utf-8" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
I am trying to call the service from a test application as,
try
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.ReceiveTimeout = new TimeSpan(10, 10, 00);
binding.SendTimeout = new TimeSpan(10, 10, 00);
binding.MaxReceivedMessageSize = Int32.MaxValue;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
EndpointAddress endpoint = new EndpointAddress("ServiceUrl");
ChannelFactory<ICRMConnectorService> channelFactory = new ChannelFactory<ICRMConnectorService>(binding, endpoint);
channelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
var service = channelFactory.CreateChannel();
service.TestMethod();
}
catch (Exception ex)
{
throw ex;
}
The call is returning an error as, The remote server returned an error: (401) Unauthorized.
Can someone please help out?