對於以前從事.net或者java開發人員,習慣了從後臺獲取網格數據(多行多列DataTable),但轉行從事android開發,不免會不習慣java
Android調用Webservice時,若是返回值是一個boolean或者string值時能夠經過下面方式接收返回值:android
SoapObject soapObject = (SoapObject) envelope.getResponse();
Re = soapObject.getProperty("twgp")
若是接收是一行值時也能夠經過上面的方式去獲取,可是若是返回的是多行多列或者一行多列的數據集時就比較麻煩了,上面的方法無論用,否則的話接收到的值永遠是第一行的值,因此對於那種多行多列的返回值時,以下面的webservice:web
//運價查詢 @SuppressWarnings("unchecked") @Repository("priceDao") public class PriceDao extends BaseOraDao { public List getPrice(String fromPort, String toPort){ List foo; StringBuffer sb = new StringBuffer(); sb.append("select max(price20gp) as price20GP,max(price40gp) as price40gp,max(price40h) "); sb.append("as price40h from "); sb.append("(select * from nqprice_main n where n.feetype='水運費' and n.fromport='"); sb.append(fromPort).append("' "); sb.append("and n.toport='").append(toPort).append("' "); sb.append("and n.endday is null order by n.beginday desc) where rownum<=2"); foo = getNqoraJdbcTemplate().query(sb.toString(), new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Price dm = new Price(); dm.setTwgp(String.valueOf(rs.getDouble("price20GP"))); dm.setFtgp(String.valueOf(rs.getDouble("price40gp"))); dm.setFtgp(String.valueOf(rs.getDouble("price40h"))); return dm; } }); return foo; } } } }
通過一天研究發現有一種辦法獲取:app
//構造數據 ArrayList<String> list = null; //web service請求 ht.call(null, envelope); //獲得返回結果 result = (SoapObject) envelope.bodyIn; for (int i = 0; i < result.getPropertyCount(); i++) { SoapObject soapChilds =(SoapObject)result.getProperty(i); list.add(soapChilds.getProperty("price20GP").toString()); } //這樣list就包含了返回列price20GP的數據
結合下面文章怎樣去調用webservicesspa
http://blog.csdn.net/sheshou2/article/details/6138865.net
大功告成!!!code