I'm trying to authenticate to a webservice php with this code in c#:
// Create the binding.
WSHttpBinding myBinding = new WSHttpBinding();
myBinding.Security.Mode = SecurityMode.None;
myBinding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Basic;
myBinding.Name = "Remessa";
myBinding.Namespace = "cramg.cra21.com.br";
myBinding.AllowCookies = true;
EndpointAddress ea = new
EndpointAddress("http://cramg.cra21.com.br/cramg/xml/protestos.php");
CRAMG.servercraPortTypeClient t =
new CRAMG.servercraPortTypeClient(myBinding, ea);
t.ClientCredentials.UserName.UserName = "cromg";
t.ClientCredentials.UserName.Password = "
t.Open();
t.Remessa("tfasd", "fasfa");
I get error 500. And with this code:
br.com.cra21.cramg.servercra a = new br.com.cra21.cramg.servercra();
System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();
a.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)";
NetworkCredential netCred = new NetworkCredential("cromg", "1234");
myCredentials.Add(new Uri(a.Url), "Basic", netCred);
a.Credentials = myCredentials;
a.UseDefaultCredentials = false;
string retorno = a.Homologadas("2");
I get this error: Authentication failed. Can anyone help?