Login Web Service Exception(716): java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

StackOverflow https://stackoverflow.com/questions/13525025

  •  01-12-2021
  •  | 
  •  

Pergunta

    ****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();         

Problem: I am getting this exception in

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?
Foi útil?

Solução

I think your response object is empty, when you try to assign it to "id" variable it gives this error

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

Check your response is null or not ? Check your web method sql query that it returns data ?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top