我有asp.net web服务,它返回Book Objects列表 我怎样才能在android中收到这个对象 这是我的网络服务
[WebMethod]
public List<Object> connectoSql()
{
Connect();
SqlCommand cmdMySQL = cnMySQL.CreateCommand();
SqlDataReader reader;
Book book = new Book();
List<Object> bookobject = new List<Object>();
cmdMySQL.CommandText = "select Name from Category where parentCategoryId is NULL";
cnMySQL.Open();
reader = cmdMySQL.ExecuteReader();
// List<Book> user = new List<Book>();
while (reader.Read())
{
String username = reader["Name"] as String;
book.setTitle(username);
book.setid(000);
bookobject.Add(book);
}
这是我的Book Book Object
public class Book
{
private String title;
private int id;
public String getTitle() {
return title;
}
public void setTitle(String title)
{
this.title=title;
}
public int getid()
{
return id;
}
public void setid(int id)
{
this.id = id;
}
public String toString()
{
return title;
}
}
}
这是我尝试获取响应但结果为空
try {
httpTransport.call(SOAP_ACTION, envelope);
SoapObject oo = (SoapObject)envelope.getResponse();
oo.getPropertyCount();
for (int i = 0; i < oo.getPropertyCount(); i++) {
Book book = (Book)oo.getProperty(i);
String title=book.getTitle();
int id=book.getid();
}
} catch (Exception exception) {
// response = exception.toString();
}
是的,任何人都可以帮助我