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;
更改DNS并将其替换为WCF工具中的IP。
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("host@host.com")
);
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.