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

Time:05-27

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]"".'

CodePudding user response:

 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.

CodePudding user response:

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.

  • Related