java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
解决方法: 导入ksoap2.jar,最后不要忘记一定要用 Add External Jars... 不能用Add Jars
然后要在Orader and Export 钩选你的ksoap2.jar,否则不会导出到APK
解析detail = (SoapObject) result.getProperty("getWeatherbyCityNameResult");
提示:
java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive
返回数组时候才有 SoapObject
如果你只输出单一的数据:
Object c=envelope.getResponse(); if(c==null) { System.out.println("return null"); return; } SoapPrimitive test=(SoapPrimitive)c; Log.i("date",test.toString()); Toast.makeText(this, c.toString(), Toast.LENGTH_LONG).show(); Log.i("date",c.toString()); return;
两种方法都可以输出正常的数据;
如何访问string[][] 二维数组?
二维数组返回一个Vector 自己解析就可以了:
//返回数组时候才可以使用SoapObject //否则java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive Vector<SoapObject> soaparray=extracted(c); for(int i=0;i<soaparray.size();i++) { SoapObject detail=soaparray.get(i); parseWeather(detail); } @SuppressWarnings("unchecked") private Vector<SoapObject> extracted(Object c) { return (Vector<SoapObject>)c; }