Iam new to Android and stuck up with something for past couple of days.
Iam retreiving CandidateNames
from database and storing it to my ArrayList
which is in a WebService
and returning the ArrayList
to Java Client.
WebService
with ArrayList
:
public ArrayList<String> DisplayName(){
ArrayList<String> results= new ArrayList<String>();
try {
String connectionURL = "jdbc:mysql://localhost/databaseName";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection=DriverManager.getConnection(connectionURL,"username","pswd");
statement = connection.createStatement();
String QueryString = "Select CName From CMaster where cid='xyz'";
rs = statement.executeQuery(QueryString);
while (rs.next()) {
results.add(rs.getString(1));
}
rs.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
return results;
}
Java Code:
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
envelope.setOutputSoapObject(request);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
System.out.println("Response:::::::::::::" +result);
}
This gives me only the first value of my ArrayList
.
When I replace: SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
with
SoapObject result= (SoapObject)envelope.getResponse();
System.out.println("Response:::::::::::::" +result.getProperty(0));
it throws the following exception
:
java.lang.classcastexception org.ksoap2.serialization.soapprimitive cannot be cast to org.ksoap2.serialization.soapObject
I Googled and tried every possible thing,please help me out if i missed out something. Thanks in advance!