Error in the android application when fetching data in postgreSQL database via WebServices with Ksoap2

0

First I made a WebService using axis 2, where the class has the connection to the database, and the class with requestsDAO with CRUD. Using SoupUI I can carry out the call of the methods. So, I created an android application to consume these services, but this one giving error when showing the database data in a ListView, when I run it appears (unfortunately XsaladaTest has stopped), already done before and it worked but now I am not getting my logcat is bugged and is not showing the log. What am I doing wrong?

XsalvationWord.java

packagecom.example.xsaladateste;publicclassPedidosXsaladaBusca{privateintid_pedidos;privateStringinformacao_adicionais;privateintmesa;privateStringnome_sobrenome_cliente;privateStringnome_xsalada;privatedoubletotal_a_pagar;PedidosXsaladaBusca(){}PedidosXsaladaBusca(intid_pedidos,Stringinformacao_adicionais,intmesa,Stringnome_sobrenome_cliente,Stringnome_xsalada,doubletotal_a_pagar){this.id_pedidos=id_pedidos;this.informacao_adicionais=informacao_adicionais;this.mesa=mesa;this.nome_sobrenome_cliente=nome_sobrenome_cliente;this.nome_xsalada=nome_xsalada;this.total_a_pagar=total_a_pagar;}publicintgetId_pedidos(){returnid_pedidos;}publicvoidsetId_pedidos(intid_pedidos){this.id_pedidos=id_pedidos;}publicStringgetNome_sobrenome_cliente(){returnnome_sobrenome_cliente;}publicvoidsetNome_sobrenome_cliente(Stringnome_sobrenome_cliente){this.nome_sobrenome_cliente=nome_sobrenome_cliente;}publicintgetMesa(){returnmesa;}publicvoidsetMesa(intmesa){this.mesa=mesa;}publicStringgetInformacao_adicionais(){returninformacao_adicionais;}publicvoidsetInformacao_adicionais(Stringinformacao_adicionais){this.informacao_adicionais=informacao_adicionais;}publicdoublegetTotal_a_pagar(){returntotal_a_pagar;}publicvoidsetTotal_a_pagar(doubletotal_a_pagar){this.total_a_pagar=total_a_pagar;}publicStringgetNome_xsalada(){returnnome_xsalada;}publicvoidsetNome_xsalada(Stringnome_xsalada){this.nome_xsalada=nome_xsalada;}@OverridepublicStringtoString(){return"PedidosXsaladaBusca [id_pedidos=" + id_pedidos + ", informacao_adicionais=" + informacao_adicionais
                + ", mesa=" + mesa + ", nome_sobrenome_cliente=" + nome_sobrenome_cliente + ", nome_xsalada="
                + nome_xsalada + ", total_a_pagar=" + total_a_pagar + "]";
    }

}

Orders.java

    public class PedidosDAO {

    // Setando Caminhos

    private static final String URL = "http://192.168.0.1:8080/BancoParaXsalada/services/PedidosDAO?wsdl";
    private static final String nameSpace = "http://xsalada.com.br";

    // referencias ao metodos no SoapUI XML file
    private static final String BUSCAR = "buscarTodos";

    // metodo inserir no banco pelo android usando biblioteca Ksoap2

    public ArrayList<PedidosXsaladaBusca> buscarTodos() {

        ArrayList<PedidosXsaladaBusca> lista = new ArrayList<PedidosXsaladaBusca>();

        SoapObject buscarTodos = new SoapObject(nameSpace, BUSCAR);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(buscarTodos);
        envelope.implicitTypes = true;

        HttpTransportSE http = new HttpTransportSE(URL);

        try {

            http.call("urn:" + BUSCAR, envelope);

            Vector<SoapObject> resposta = (Vector<SoapObject>) envelope.getResponse();

            for (SoapObject soapObject : resposta) {
                PedidosXsaladaBusca user = new PedidosXsaladaBusca();

                user.setId_pedidos(Integer.parseInt(soapObject.getProperty("id_pedidos").toString()));

                user.setInformacao_adicionais(soapObject.getProperty("informacao_adicionais").toString());

                user.setMesa(Integer.parseInt(soapObject.getProperty("mesa").toString()));

                user.setNome_sobrenome_cliente(soapObject.getProperty("nome_sobrenome_cliente").toString());

                user.setNome_xsalada(soapObject.getProperty("nome_xsalada").toString());

                user.setTotal_a_pagar(Double.parseDouble(soapObject.getProperty("total_a_pagar").toString()));

                lista.add(user);

            }

        } catch (Exception e) {

            e.printStackTrace();

            return null;
        }

        return lista;
    }
}

MainActivity.java

public class MainActivity extends Activity {
public ListView listaUsuario = (ListView) findViewById(R.id.listaPedidos);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (android.os.Build.VERSION.SDK_INT > 9) {

        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);

    }

    PedidosDAO dao = new PedidosDAO();
    ArrayList<PedidosXsaladaBusca> lista = dao.buscarTodos();

    ArrayAdapter<PedidosXsaladaBusca> adpUser = new ArrayAdapter<PedidosXsaladaBusca>(this,
            android.R.layout.simple_list_item_1, lista);
    listaUsuario.setAdapter(adpUser);

}
    
asked by anonymous 14.12.2015 / 15:42

1 answer

0

Then I researched and managed to solve. follow below the link I found to resolve the error:

link

    
15.12.2015 / 20:55