我正在嘗試使用 .NET 6 客戶端使用 SOAP 服務。該服務使用基本身份驗證。我收到錯誤:
HTTP 請求未經客戶端身份驗證方案“基本”授權。從服務器收到的身份驗證標頭是“基本領域=“自定義領域””。
我的代碼是 - 創建系結:
private HttpBindingBase CreateHttpsBinding()
{
var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
binding.Security.Mode = BasicHttpsSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.MessageEncoding = WSMessageEncoding.Mtom;
binding.TransferMode = System.ServiceModel.TransferMode.Buffered;
binding.MaxBufferSize = int.MaxValue;
binding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
binding.MaxReceivedMessageSize = int.MaxValue;
return binding;
}
并創建客戶端:
var binding = CreateHttpsBinding();
using (var wsClient = new ExternalService(binding, new EndpointAddress(url)))
{
wsClient.ClientCredentials.UserName.UserName = param.Username;
wsClient.ClientCredentials.UserName.Password = param.Password;
await wsClient.OpenAsync();
var response= await wsClient.SomeCall(input);
該錯誤作為 wsClient.SomeCall() 上的例外給出;
uj5u.com熱心網友回復:
似乎是因為用戶名/密碼的詳細資訊而給出了錯誤!
最初它令人擔憂,因為在 .NET Core 中無法在系結安全配置中設定 Realm。但這似乎不是問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/537229.html
上一篇:如何實時更改MySql資料庫,資料庫并在前端有即時回應
下一篇:洗掉 和獲得有效的XML?
