J'ai un service Web basé sur Java qui nécessite une authentification de base pour communiquer avec lui. Si je tape l'URL WSDL dans mon navigateur, je suis invité pour l'authentification de base. Ce que je peux obtenir en entrant les informations d'identification correctes. Cependant, l'utilisation de mon client WCF ne fonctionne pas.Pourquoi Basic Auth ne fonctionne pas avec mon client WCF au service Web Java SOAP?
Je construis mon client WCF comme ceci:
var binding = new BasicHttpBinding
{
MaxReceivedMessageSize = 2048 * 10240,
Security = {
Mode = BasicHttpSecurityMode.TransportCredentialOnly,
Transport = {
ClientCredentialType = HttpClientCredentialType.Basic,
Realm = "MYREALM",
ProxyCredentialType = HttpProxyCredentialType.None
},
Message = {
ClientCredentialType = BasicHttpMessageCredentialType.UserName,
AlgorithmSuite = SecurityAlgorithmSuite.Default
}
}
};
var client = new WebServiceClient(binding, endpoint);
client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
client.DoWebServiceMethod();
je reçois l'exception suivante.
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Basic realm="MYREALM"'.
D'après ce que je peux dire, je fais les choses correctement. Où vais-je mal?