I am developing an Android app which uses a Web Service. I added a web service reference to my project (Right-Click on project -> Add Web Reference). When I use the web service without authentication everything works fine, but when I set credentials they are just not working. I'm getting this error:
The request failed with HTTP status 401: Unauthorized
Maybe someone can help me?
This is button click event function:
button.Click += delegate {
WebReference.WebPhysInvPocess client = new WebReference.WebPhysInvPocess(); //this is my web service
client.Credentials = new NetworkCredential("username", "password"); //adding crediantials
//client.Url = @"http://localhost:7053/DynamicsNAV-NAV6R2Prototype/WS/NVB%20Prototype/Codeunit/WebPhysInvPocess";
string blabla = "";
try
{
client.CratePhysInvBatch("S001", "RAUDONAS", ref blabla, "test");
TextView txt = FindViewById<TextView>(Resource.Id.textView1);
}
catch (Exception e)
{
TextView txt = FindViewById<TextView>(Resource.Id.textView1);
txt.Text = e.Message;
}
};
When I compile the code as a windows .net application everything works.