如何解析android访问webservice返回的SoapObject数据(可用)

时间:2021-12-28 18:04:55

怎么解析android访问webservice返回的SoapObject数据

本帖最后由 kkDragon123 于 2013-03-26 15:50:07 编辑

我的数据如下:
mingdanResponse{mingdanResult=anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; }; }; }; }; }; unique=anyType{selector=anyType{}; field=anyType{}; }; }; }; diffgram=anyType{DocumentElement=anyType{xyWaiFang=anyType{id=33; ajbh=EGVGQCIUA0278; Shuoming=垃圾堆里发生率 ; wfAdd=河南省郑州市郑东新区商务内环路2号中油新澳大厦706A郑州东方三力; FromYwy=sdws003; ToYwy=admin; Addtime=2012-07-31T16:38:21.597+08:00; Lasttime=2013-01-23T17:07:46.04+08:00; wfState=Fresh; addID=2602; ajid=2630; xm=张永明; dqsj=2012-09-21T00:00:00+08:00; }; xyWaiFang=anyType{id=35; ajbh=EGVGQCIUA0248; Shuoming=anyType{}; wfAdd=山东省济南市历城区汇科旺园小区3号楼2单元1702号; FromYwy=admin; ToYwy=admin; Addtime=2012-12-17T15:44:17.14+08:00; Lasttime=2013-02-21T14:14:08.1+08:00; wfState=Fresh; addID=2509; ajid=2600; xm=亓卫国; dqsj=2012-09-21T00:00:00+08:00; }; }; }; }; }

不知道为什么,前面多了很多看不懂的代码。然后我用的网上的方法解析:

SoapObject result = (SoapObject)envelope.getResponse();
for (int i = 0; i < result.getPropertyCount(); i++){
SoapObject soap = (SoapObject) result.getProperty(i);//到这一行数据好像没动,下面的xm也没取到
String xm =soap.getProperty("xm").toString();

------解决方案--------------------------------------------------------
自己解决了。

SoapObject result = (SoapObject)envelope.getResponse();
result = (SoapObject)result.getProperty(1);
result = (SoapObject)result.getProperty(0);
for(int i=0; i< result.getPropertyCount(); i++ ){
HashMap<String, String> map=new HashMap<String, String>();
SoapObject soap = (SoapObject) result.getProperty(i);
String xm =soap.getProperty("xm").toString();
String zhuangtai =soap.getProperty("wfState").toString();
String dizhi =soap.getProperty("wfAdd").toString();

转:http://www.myexception.cn/android/1255885.html