Hello
I want to consume a web service from a winform .net application (developed by an other firm in asp.net) and it requires an authentification
So i tried to send a credential to it, but i receive an http 401 error unautorized
So i checked out what is the soap message sent from my client, but it doesn't contain any authentification in the header
This is my code :
CredentialCache v_Credential = new CredentialCache();
ServiceCodaAuthentifie.InputService v_ServiceScoda = new ServiceCodaAuthentifie.InputService();
string v_LoginAuthentificationToCodaWebService = ConfigurationSettings.AppSettings[CODA_LOGIN_WEB_SERVICE];
string v_PassWordAuthentificationToCodaWebService = ConfigurationSettings.AppSettings[CODA_PASSWORD_WEB_SERVICE];
v_Credential.Add(new Uri(v_ServiceScoda.Url), "Basic", new NetworkCredential(v_LoginAuthentificationToCodaWebService, v_PassWordAuthentificationToCodaWebService,""));
//v_ServiceScoda.Credentials = v_Credential;
v_ServiceScoda.Credentials = new NetworkCredential(v_LoginAuthentificationToCodaWebService, v_PassWordAuthentificationToCodaWebService, "");
v_ServiceScoda.PostToBooks(new TestAuthentificationWebService.ServiceCodaAuthentifie.PostToBooksRequest());
CredentialCache v_Credential = new CredentialCache();
.InputService v_Service = new InputService();
string login = "test";
string password = "test";
v_Credential.Add(new Uri(v_Service.Url), "Basic", new NetworkCredential(login,password,""));
v_ServiceScoda.Credentials = v_Credential;
v_Service.Method1();
I tried also to change 'Basic' to 'Negotiate', to add a domain but nothing works
and also saw on forums, that i needed to instantiate a class that derives from soapheader developed by the creator of the web service : http://www.codeproject.com/KB/cpp/authforwebservices.aspx
so what is the good way ? use the specific class, or the properties 'Credentials'
and why doesn't it work on my example