簡體   English   中英

從.Net Core 2.1使用WCF服務器時出錯,但在.NET上沒問題

[英]Get an error when consuming a WCF server from .Net Core 2.1 but it's fine on .NET

我在Microsoft Dynamics AX上有一個WCF服務(AIF)

我可以使用.NET 4.6.1毫無問題地調用它。 但是,當我使用.NET Core運行相同的確切代碼時,我得到一個錯誤

對SSPI的調用失敗目標主體名稱不正確

在此輸入圖像描述

關於這個錯誤有許多相似的問題,但解決方案並不能解決我的問題。

    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。

在Connected Services \\ MyService \\ Rference.cs文件中,找到方法GetEndpointAddress()並將UpnEndpointIdentity與您的身份帳戶一起添加。

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));
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM