How to send an arraylist by ksoap?

0

Greetings I have a doubt when sending an array list by means of ksoap, so far I have sent simple data such as numbers, text but now I want to send a complete table stored in sqlite.

The first step I take is to read a whole table stored in sqlite by means of this function.

public ArrayList<String> GetAllValues(String aTable)
{
    list = new ArrayList<String>();
    db = getReadableDatabase();

    String selectQuery = "SELECT  * FROM " + aTable;

    SQLiteDatabase db = this.getReadableDatabase();

    Cursor cursor = db.rawQuery(selectQuery, null);

    if (cursor.moveToFirst())
    {
        do
        {
            list.add(cursor.getString(1));//latitud
            list.add(cursor.getString(2));//longitud
        }
        while (cursor.moveToNext());
    }
    if (cursor != null && !cursor.isClosed())
    {
        cursor.close();
    }
    return list;
}

Once the temin read and stored in the variable "list" I try to send it to a webservice through KSOAP2 for which I occupy this function. My question is how do I incorporate the varibale list so that all the data stored in it are sent correctly?

private class TareaWSInsercion1 extends AsyncTask<String, Integer, Boolean> {
    final String NAMESPACE = "http://prueba1.com/";
    final String URL = "http://prueba1.com/ServicioPrueba.asmx";
    final String METHOD_NAME = "MtdCoordenadas";
    final String SOAP_ACTION = "http://prueba1.com/MtdCoordenadas";

    protected Boolean doInBackground(String... params) {

        boolean resul = true;


        try {

            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);



            //request.addProperty("NOMBRE", Nombre);



            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE transportSE = new HttpTransportSE(URL);
            try {
                transportSE.call(SOAP_ACTION, envelope);
                SoapPrimitive resultado_xml = null;
                resultado_xml = (SoapPrimitive) envelope.getResponse();
                String res = resultado_xml.toString();
                if (res.equals("1")) {
                    resul = true;
                } else {

                }
            } catch (Exception e) {
                resul = false;
            }
            return resul;
        } catch (Exception e) {

        }
        return resul;
    }
}

Thank you.

    
asked by Charlie S 29.10.2017 в 23:00
source

1 answer

0

The List object is not a type that KSOAP can send, KSOAP is designed to send primitive data, so LIST does not belong to them. That's why they created the serialization and deserialization so you can deserialize an object.

    
answered by 30.10.2017 / 19:43
source