如何修复使用默认绑定在 .NET Core 中使用 Web 服务时出现的“TransportBindingElement”错误?

问题描述 投票:0回答:1

我正在尝试在我的 dotnet core7 项目中使用 Web 服务。 我无权访问该服务本身。 当我尝试调用服务方法时,它返回该错误:

具有合约“IMyService”的 ServiceEndpoint 上的 CustomBinding 缺少 TransportBindingElement。
每个绑定必须至少有一个派生自 TransportBindingElement 的绑定元素。'

虽然它在引用中使用默认绑定。

我该如何解决它。

我尝试覆盖客户端配置。但它也不起作用。 私有静态System.ServiceModel.Channels.Binding GetBindingForEndpoint(TimeSpan超时) { var httpsBinding = new BasicHttpsBinding(); httpsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; httpsBinding.Security.Mode = BasicHttpsSecurityMode.Transport;

        var integerMaxValue = int.MaxValue;
        httpsBinding.MaxBufferSize = integerMaxValue;
        httpsBinding.MaxReceivedMessageSize = integerMaxValue;
        httpsBinding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
        httpsBinding.AllowCookies = true;

        httpsBinding.ReceiveTimeout = timeout;
        httpsBinding.SendTimeout = timeout;
        httpsBinding.OpenTimeout = timeout;
        httpsBinding.CloseTimeout = timeout;

        return httpsBinding;
    }

在创建客户端时: _RedemptionServiceClient = new RedemptionLiteIntegrationServiceClient("https://78.93.37.230:9799/RedemptionLiteIntegrationServiceBasicHttpEndPoint", new TimeSpan(1, 30, 0),"","");

web-services .net-core soap
1个回答
0
投票

我也有同样的问题。您必须将 System.ServiceModel.* 更新到最新版本。

© www.soinside.com 2019 - 2024. All rights reserved.