對于我閱讀和理解的內容,當我不發送身份驗證時會發生這種情況。
但我嘗試通過兩種方式發送它:
string userN = "username";
string _pasw = "password";
BasicHttpBinding binding = new BasicHttpBinding();
Endpoint wsdl = new Endpoint("MyEndpoint");
SoapClient client = new SoapClient(binding, wsdl);
client.ClientCredentials.UserName.UserName = userN;
client.ClientCredentials.UserName.Password = _pasw;
await client.OpenAsync();
和:
HttpClient request = new HttpClient();
var svcCredentianls = Encoding.ASCII.GetBytes(userN ":" _pasw);
request.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(svcCredentianls));
但以一種或另一種方式,我遇到了這個錯誤:
System.ServiceModel.Security.MessageSecurityException: 'HTTP 請求未經“匿名”客戶端身份驗證方案授權。從服務器收到的身份驗證標頭是“Basic realm="SAP NetWeaver Application Server [PRD/400]"”。
我錯在哪里或我錯過了什么?
uj5u.com熱心網友回復:
我相信問題出在您的 web.config 中的系結配置上。請檢查安全節點。
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" realm="" />
</security>
您可以在下面找到我的作業示例:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://pc:8080/Service.svc/SslService" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService"
name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
如果您不使用 web.config 配置,您可以嘗試調整您的 BasicHttpBinding 創建代碼:
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/486043.html
上一篇:郵政服務沒有從Angular前端更新價值,但它在郵遞員中作業
下一篇:Symfony“代理”網路服務?