0

I want to fetch a listview from webservice in Android app. I managed to get the data when i tried to break my code. But this is what I get when i break the code in the array list: [com.xxx.example.Hotels@41319dc0, com.xxx.example.Hotels@4131a518, com.xxx.example.Hotels@4132fec8, com.xxx.example.Hotels@413323a0]

Below is my code that called the list.

mainListView = (ListView) findViewById(R.id.lview);
    WebService2 cs = new WebService2();
    listHt = cs.selectAllHotels();
    listAdapter = new HotelArrayAdapter(this, listHt);
    mainListView.setAdapter(listAdapter);

Below is the code called the webservice.

public ArrayList<Hotels> selectAllHotels() {
    ArrayList<Hotels> lst = new ArrayList<Hotels>();
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    SoapObject table = null;
    SoapObject responseBody = null;

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {

        androidHttpTransport.call(SOAP_ACTION, envelope);
        responseBody = (SoapObject) envelope.getResponse();

        responseBody = (SoapObject) responseBody.getProperty(1);
        table = (SoapObject) responseBody.getProperty(0);

        for (int i = 0; i < table.getPropertyCount(); i++) {
            Hotels dto = new Hotels();
            SoapObject row = (SoapObject) table.getProperty(i);
            dto.setName(row.getProperty("HOTELNAME").toString());
            lst.add(dto);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return lst;
}
angie1289
  • 1
  • 3
  • Your array list is of type Hotels, if you want to get properties from Hotels object then you may call appropriate getMethods from Hotels object class. – darwin Jan 14 '16 at 04:18
  • give this example a try http://stackoverflow.com/questions/34368029/how-to-send-a-soap-request-using-webservicetemplate/34368514#34368514 – Pankaj Nimgade Jan 14 '16 at 05:29

0 Answers0