Description
Hi,
I am trying to consume WCF service from .net core web api client app. The service needs following three settings on client side:
-
Custom HTTP headers to pass user email and ID
-
Client Credentials settings as :
credentials.Windows.ClientCredential.Domain = Domain;
credentials.Windows.ClientCredential.UserName = UserName;
credentials.Windows.ClientCredential.Password = Password;
credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Delegation; -
userPrincipalName from app.config
When I pass above info from windows app client(NOTE: this client is not .net core windows app but just .net windows app), i am able to call service methods correctly.
To reflect above settings in .net core web api app, i have made following changes:
-
using (new OperationContextScope(clientObj.InnerChannel))
{
// Add a HTTP Header to an outgoing request
HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
requestMessage.Headers[user_email] = "some text";
requestMessage.Headers[user_id] = "some text";
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
} -
ContractServiceClient clientObj = new ContractServiceClient(ContractServiceClient.EndpointConfiguration.WSHttpBinding_IContractService); NetworkCredential myCreds = new NetworkCredential("user", "pwd", "AMR"); clientObj.ClientCredentials.Windows.ClientCredential = myCreds; clientObj.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
-
UpnEndpointIdentity endpointIdentity2 = new UpnEndpointIdentity("email.com");
if ((endpointConfiguration == EndpointConfiguration.WSHttpBinding_IContractService))
{
return new System.ServiceModel.EndpointAddress(new System.Uri("servicename.svc"), endpointIdentity2, null);
}
After this, i get following exception in .net core web api client:
MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate, NTLM, Basic realm="service name"
Any pointers highly appreciated. Thanks in advance..