2012-11-23 55 views
1
****android side:** 
     Permission is also added in Android mainfest.xml  
     **webMethod.java**** 
SoapObject request = new SoapObject(SOAPNAMESPACE,SOAPLOGINMETHOD); 
request.addProperty("Username",Username); 
request.addProperty("Password",Password); 
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 
    Log.d("parameter out",""+ envelope.bodyOut.toString()); 
    try{HttpTransportSE httpTransport = new HttpTransportSE(SOAPURL); 
    httpTransport.call(SOAPLOGINACTION, envelope); 
    SoapObject response=(SoapObject) envelope.bodyIn; 
    Log.d("parameter in",""+ envelope.bodyIn); 
    id=response.getProperty(0).toString(); 

****DOTNETWEBSERVICE side:** 
[WebMethod] 
public string LoginCheck(string username, string password)//,int waitId,string phoneName,string phoneStatus,string time,string date) 
{ 
    string userID1 = null; 
    int d = 0,ds=0; 
    string path = "Data Source=UX-PC;Initial Catalog=ResturantOrdingSystem;User ID=sa;Password=123"; 
    SqlConnection con = new SqlConnection(path); 
    try 
    { con.Open(); } 
    catch (Exception exx) { } 
    // string sql = "SELECT * FROM HR Where username='" + username + "'AND password='" + password + "'"; 
    string sql = "SELECT * FROM HR Where position='waiter' AND username='" + username + "'AND password='" + password + "'"; 
    //+ "'AND position=waiter'" 

    SqlCommand CMD = new SqlCommand(sql, con); 
    dr = CMD.ExecuteReader(); 

    while (dr.Read()) 
    { 
     userID1 = (string)dr["name"]; 
    } con.Close();   

問題: 我得到這個例外登錄Web服務異常(716):java.lang.ArrayIndexOutOfBoundsException:length = 0;指數= 0

logtrace: Exception(716): java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 
i am using ksoap2-android-assembly-2.6.0-jar-with-dependencies 
Please describe me tell me solution? 

回答

2

我認爲你的反應對象是空的,當您嘗試將其指定爲「ID」變量它給這個錯誤

id=response.getProperty(0).toString(); 

檢查您的回覆爲空或不是? 檢查你的web方法sql查詢它返回的數據?

+0

同意。它似乎 –

+0

是的它是空....但在web服務它返回用戶的名稱,這是我的字符串返回類型的web服務webmethod – omeriqbal

+1

所以告訴我解決方案什麼sholud我做? – omeriqbal

相關問題