1

I'm trying to access a soap webservice i .net Core 3.1 I did add the service via Microsoft WCF Web Service Reference Provider (I typed username and password to get access.)

But I have some login issues with it.

If I try a simpel HttpClient it works fine and I get access like this:

  CredentialCache credentialCache = new CredentialCache();
  credentialCache.Add(new Uri("http://xxx"), "Negotiate", new NetworkCredential(strUserName, strPassword, strDomain));
        HttpClientHandler handler = new HttpClientHandler();
        handler.Credentials = credentialCache;
        var httpClient = new HttpClient(handler);

But with the WCF Web Service Reference I get this error: One or more errors occurred. (The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate'.)'

var client = new xxClient();
var task = Task.Run(async () => await client.GetContactsFromEmailAsync(_test).ConfigureAwait(false)) ;
Console.WriteLine(task.Result.ToString());

So how do I make my client "Negotiate" ? Or what else do I need to do?

Amigo
  • 47
  • 8
  • 1
    I haven't used `CredentialCache` before, but from what you are saying, it appears as if a "Negotiate" HTTP header is being set with the credentials in your first example and not in the second. Take a look at this [stackoverflow answer](https://stackoverflow.com/a/22998513/8252265) showing how to add headers to a SOAP request. – peterpie Jun 15 '20 at 18:01

0 Answers0