J'ai remarqué dans .NET4 que le protocole SoapHttpClientProtocol semble mettre en cache les informations d'identification du proxy. Est-ce que quelqu'un sait si cela est vrai, et comment rafraîchir ce cache? Si mes utilisateurs changent leurs informations d'identification, je voudrais les essayer, mais une fois que j'ai obtenu un protocole SoapHttpClientProtocol pour se connecter avec succès, tout appel à invoquer semble fonctionner.SoapHttpClientProtocol met en cache les informations d'identification du proxy?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Web.Services;
class Program : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public Program()
{
base.Url = "something";
}
static void Main(string[] args)
{
Program x = new Program();
x.Proxy = new WebProxy("basicproxy", 2121);
x.Proxy.Credentials = new NetworkCredential("proxyuser", "IncorrectPassword");
Console.WriteLine("Attempt with proxyuser and IncorrectPassword: " + x.NoOp());
x.Proxy.Credentials = new NetworkCredential("proxyuser", "password");
Console.WriteLine("Attempt with proxyuser and password: " + x.NoOp());
x.Proxy.Credentials = new NetworkCredential("proxyuser", "IncorrectPassword");
Console.WriteLine("Attempt with proxyuser and IncorrectPassword: " + x.NoOp());
Program y = new Program();
y.Proxy = new WebProxy("basicproxy", 2121);
y.Proxy.Credentials = new NetworkCredential("proxyuser", "IncorrectPassword");
Console.WriteLine("Attempt with proxyuser and IncorrectPassword: " + y.NoOp());
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("...", RequestNamespace = "...", ResponseNamespace = "...", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public bool NoOp()
{
try
{
object[] results = this.Invoke("NoOp", new object[0]);
return ((bool)(results[0]));
}
catch (WebException e)
{
if (e.Response != null && ((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.ProxyAuthenticationRequired)
{
Console.WriteLine("incorrect Credential attempt!");
}
else
{
Console.WriteLine("Exception: " + e.Message);
}
}
return false;
}
La sortie de ce programme (je prévois les deux derniers faux)
incorrect Credential attempt!
Attempt with proxyuser and IncorrectPassword: False
Attempt with proxyuser and password: True
Attempt with proxyuser and IncorrectPassword: True
Attempt with proxyuser and IncorrectPassword: True
Merci Pent! Changer le nom du groupe de connexion a fait l'affaire. L'utilisateur: pass @ host: le port échouerait à s'authentifier tous ensemble, bizarrement. Changer le nom du groupe de connexion semble assez sûr, mais croyez-vous qu'il y ait des implications de sécurité pour l'une de ces méthodes? – Dlongnecker
Yup, le schéma proxyuser ne fonctionnera pas: Exception non gérée: System.NotSupportedException: ServicePointManager ne prend pas en charge les proxys avec le schéma proxyuser. – Dlongnecker