Carl Patenaude Poulin
Carl Patenaude Poulin

Reputation: 6570

How can my UWP app authenticate with a WCF service?

I'm writing an UWP app in C#, and I'm trying to have it consume data from a (pre-existing) WCF service. I can't find any information online on the subject. Here is what my code looks like (WCF service is Serv, service namespace is Ns):

var config = Ns.ServClient.EndpointConfiguration.BasicHttpBinding_IServ;
var client = new Ns.ServClient(config);
var result = client.TestCall();

I get the following exception, which I don't understand how to parse:

Exception thrown: 'System.ServiceModel.Security.MessageSecurityException' in mscorlib.ni.dll

Additional information: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate, NTLM'.

What does this error message mean? And how do I successfully authenticate with the WCF service?

Bonus question: what is the ServiceReferences.Designer.ClientConfig file? How do I use it?

Upvotes: 2

Views: 552

Answers (1)

Carl Patenaude Poulin
Carl Patenaude Poulin

Reputation: 6570

I opened the Package.appxmanifest file and added the Enterprise Authentication and Private Networks (Client & Server) capabilities. This fixed the issue.

Upvotes: 3

Related Questions