简体   繁体   中英

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

I had an authentication problem with my Soap Client, which was not receiving the credentials correctly. It is a basic authentication (username and password), and apparently it was a binding problem.

For the authentication problem I jumped this problem:

System.ServiceModel.Security.MessageSecurityException: 'The HTTP request is not authorized with the "Anonymous" client authentication scheme. The authentication header received from the server was "Basic realm="SAP NetWeaver Application Server [PRD/400]"".'

To resolve it use binding.Security.Mode = BasicHttpSecurityMode.Transport; . But now I have a new problem that says:

System.ArgumentException: 'The supplied URI scheme "http" is invalid; "https" was expected. Arg_ParamName_Name'

What I don't understand is why it tells me that the scheme is HTTP and expects HTTPS, when I'm using a BasicHttpSecurityMode.Transport, which provides security is 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();

enter image description here

EDIT:

Now im trying to use BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

But this gives me the same first error:

System.ServiceModel.Security.MessageSecurityException: 'The HTTP request is not authorized with the "Anonymous" client authentication scheme. The authentication header received from the server was "Basic realm="SAP NetWeaver Application Server [PRD/400]"".'

 binding.Security.Mode = BasicHttpSecurityMode.Transport;

Sets it to HTTPS, but you are passing something that is HTTP. If endpoint is HTTP and not HTTPS it will fail.

System.ServiceModel.Security.MessageSecurityException: 'The HTTP request is not authorized with the "Anonymous" client authentication scheme. The authentication header received from the server was "Basic realm="SAP NetWeaver Application Server [PRD/400]"".'

A wrong password can also be the cause of this error message.
Make sure that the configuration of the server and client is the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM