簡體   English   中英

我有 HTTP 方案並且需要 HTTPS,但我的綁定是 BasicHttpSecurityMode.Transport; 我的端點是 HTTP

[英]I have HTTP scheme and HTTPS is expected, but my binding is BasicHttpSecurityMode.Transport; And my EndPoint is HTTP

我的 Soap 客戶端出現身份驗證問題,它沒有正確接收憑據。 這是一個基本的身份驗證(用戶名和密碼),顯然這是一個綁定問題。

對於身份驗證問題,我跳過了這個問題:

System.ServiceModel.Security.MessageSecurityException: 'HTTP 請求未經“匿名”客戶端身份驗證方案授權。 從服務器收到的身份驗證標頭是“Basic realm="SAP NetWeaver Application Server [PRD/400]"”。

要解決它,請使用binding.Security.Mode = BasicHttpSecurityMode.Transport; . 但現在我有一個新問題說:

System.ArgumentException: '提供的 URI 方案“http”無效; “https”是預期的。 Arg_ParamName_Name'

我不明白的是為什么當我使用提供安全性的 BasicHttpSecurityMode.Transport 是 HTTPS 時,它告訴我方案是 HTTP 並需要 HTTPS

 BasicHttpBinding binding = new BasicHttpBinding(); 
 binding.Security.Mode = BasicHttpSecurityMode.Transport;

 SoapClient client = new SoapClient(binding, endpoint);
 client.ClientCredentials.UserName.UserName = _userName;
 client.ClientCredentials.UserName.Password = _password;                
 await client.OpenAsync();

在此處輸入圖像描述

編輯:

現在我嘗試使用BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

但這給了我同樣的第一個錯誤:

System.ServiceModel.Security.MessageSecurityException: 'HTTP 請求未經“匿名”客戶端身份驗證方案授權。 從服務器收到的身份驗證標頭是“Basic realm="SAP NetWeaver Application Server [PRD/400]"”。

 binding.Security.Mode = BasicHttpSecurityMode.Transport;

將其設置為 HTTPS,但您傳遞的是 HTTP。 如果端點是 HTTP 而不是 HTTPS,它將失敗。

System.ServiceModel.Security.MessageSecurityException: 'HTTP 請求未經“匿名”客戶端身份驗證方案授權。 從服務器收到的身份驗證標頭是“Basic realm="SAP NetWeaver Application Server [PRD/400]"”。

錯誤的密碼也可能是此錯誤消息的原因。
確保服務器和客戶端的配置相同。

暫無
暫無

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

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