2012-11-19 65 views
4

我正在開發使用Web服務的Android應用程序。我爲我的項目添加了一個Web服務引用(右鍵單擊項目 - >添加Web引用)。當我使用Web服務而不進行身份驗證時,一切正常,但是當我設置憑據時,它們只是不起作用。我得到這個錯誤:使用授權的Web服務的Android單聲道

The request failed with HTTP status 401: Unauthorized

也許有人可以幫助我嗎?

這是按鈕單擊事件功能:

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; 
     } 

    }; 

當我編譯代碼爲Windows .NET應用程序一切正常。

回答

0

您是否檢查了您的代表團?