I have a WCF service (AIF) on Microsoft Dynamics AX
I can call it without any problem using .NET 4.6.1
. However, when I run the same exact code using .NET Core
I get an error which states
A call to SSPI failed The target principal name is incorrect
There are many alike questions out there about this error but the solutions does not fix my problem.
var service = new MarketplaceGetItemsDataServiceClient();
service.ClientCredentials.Windows.ClientCredential.UserName = "UserName";
service.ClientCredentials.Windows.ClientCredential.Password = "P@ssword";
service.ClientCredentials.Windows.ClientCredential.Domain = "Domain";
var result = service.GetItemsDataAsync(new CallContext(), new SearchOptionsDC() { VendorId = "0000" }).Result;
In Connected Services\MyService\Rference.cs file find the method GetEndpointAddress() and add the UpnEndpointIdentity with your identity account.
private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.NetTcpBinding_MyService))
{
return new System.ServiceModel.EndpointAddress(
new System.Uri(@"net.tcp://190.188.1.2:8201/DynamicsAx/Services/MyService"),
new System.ServiceModel.UpnEndpointIdentity("[email protected]")
);
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
Change the DNS and replace it with the IP in the WCF tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With