肥皂解析工作..但不是理想的结果

时间:2014-06-19 10:49:47

标签: android soap

我能够解析。但不是一个确切的方式。我有以下来自Ksoap的回复:

anyType{ResponseCode=0; ResponseDescription=Success.; Pickups=anyType{Pickup=anyType{PickupExecutive=Arun Kanojia; PickupExecutiveId=0; ResponseCode=0; PickupPriority=anyType{}; PickupPriorityId=1; CustomerAccode=2895; CustomerName=Test ; CustomerContact=9810530861; CustomerAddress=anyType{}; CustomerEmail=vishal.nigam@computerware.co; PickupStatusId=1; PickupId=2; PickupDate=2014-05-27T13:33:17; PickupPendingSince=0001-01-01T00:00:00;PickupItems=anyType{PickupItem=anyType{ResponseCode=0; CustomerCAFNo=S123456789; ItemSerial=8944538524000775370; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=2; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=MultiIMSI; ItemCountryId=277; }; }; }; Pickup=anyType{PickupExecutive=Arun Kanojia; PickupExecutiveId=0; ResponseCode=0; PickupPriority=anyType{}; PickupPriorityId=1; CustomerAccode=104327; CustomerName=SAP LABS INDIA PVT LTD; CustomerContact=9810530861; CustomerAddress=138 , Export Promotion Industrial ParkWhitefieldBANGALORE; CustomerEmail=vishal.nigam@computerware.co; PickupStatusId=1; PickupId=3; PickupDate=2014-05-27T13:33:17; PickupPendingSince=0001-01-01T00:00:00; PickupItems=anyType{PickupItem=anyType{ResponseCode=0; CustomerCAFNo=T1000517191; ItemSerial=89014103276033399004; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=3; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=USA; ItemCountryId=9; }; PickupItem=anyType{ResponseCode=0; CustomerCAFNo=T1000517192; ItemSerial=89014103276033399061; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=3; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=USA; ItemCountryId=9; }; PickupItem=anyType{ResponseCode=0; CustomerCAFNo=T1000517193; ItemSerial=89014103276033399087; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=3; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=USA; ItemCountryId=9; }; PickupItem=anyType{ResponseCode=0; CustomerCAFNo=T1000517194; ItemSerial=89014103276033399988; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=3; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=USA; ItemCountryId=9; }; PickupItem=anyType{ResponseCode=0; CustomerCAFNo=T1000517195; ItemSerial=89014103276132316461; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=3; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=USA; ItemCountryId=9; }; }; }; Pickup=anyType{PickupExecutive=Arun Kanojia; PickupExecutiveId=0; ResponseCode=0; PickupPriority=anyType{}; PickupPriorityId=0; CustomerAccode=204463; CustomerName=Prateek Jain ; CustomerContact=9810530861; CustomerAddress=H No. 103 Mann EnclaveHembag PatialaPunjab; CustomerEmail=vishal.nigam@computerware.co; PickupStatusId=1; PickupId=4; PickupDate=2014-05-27T13:33:17; PickupPendingSince=0001-01-01T00:00:00; PickupItems=anyType{PickupItem=anyType{ResponseCode=0; CustomerCAFNo=M987564; ItemSerial=89610300000486743575; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=4; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=MultiIMSI; ItemCountryId=277; }; }; }; Pickup=anyType{PickupExecutive=Arun Kanojia; PickupExecutiveId=0; ResponseCode=0; PickupPriority=anyType{}; PickupPriorityId=1; CustomerAccode=371313; CustomerName=Desa Raju Ramachandra Rao ; CustomerContact=9810530861; CustomerAddress=Room -346, Ix Block, Mit Hostels , Manipal, UDUPI; CustomerEmail=vishal.nigam@computerware.co; PickupStatusId=1; PickupId=5; PickupDate=2014-05-27T13:33:17; PickupPendingSince=0001-01-01T00:00:00; PickupItems=anyType{PickupItem=anyType{ResponseCode=0; CustomerCAFNo=M4010702; ItemSerial=8949226130603440952; ItemType=SIM; ItemTypeId=1; ItemAction=anyType{}; ItemActionId=0; PickupDate=2014-05-27T13:33:17; PickupId=5; ItemRemark=anyType{}; IsValidItem=true; ItemCountry=Germany

我正在使用以下代码:

            SoapObject result = (SoapObject)envelope.getResponse();
            int resultcount = result.getPropertyCount();
            Log.i("resultCount", resultcount +"");
            for(int k=0; k<resultcount; k++){
            SoapObject Pickups = (SoapObject) result.getProperty("Pickups");
            SoapObject Pickup = (SoapObject) Pickups.getProperty(k);

            for(int m=0; m<Pickups.getPropertyCount(); m++){
            SoapObject PickupM = (SoapObject) Pickups.getProperty(m);
            for(int l=2; l<PickupM.getPropertyCount(); l++){
             PropertyInfo pp = new PropertyInfo();
             PickupM.getPropertyInfo(l, pp);
             String name = pp.name;
             String val = PickupM.getProperty(l).toString();

             if(name.equals("PickupExecutive")&&(!val.equals("anyType{}"))){
                 pickupExecutive = val;
             }
             if(name.equals("PickupExecutiveId")&&(!val.equals("anyType{}"))){
                 pickupExecutiveId = Integer.parseInt(val);
             }
             if(name.equals("PickupPriority")&&(!val.equals("anyType{}"))){
                 pickupPriority = val;
             }
             if(name.equals("PickupPriorityId")&&(!val.equals("anyType{}"))){
                 pickupPriorityId = Integer.parseInt(val);
             }
             if(name.equals("CustomerAccode")&&(!val.equals("anyType{}"))){
                 customerAccode = Integer.parseInt(val);
             }
             if(name.equals("CustomerName")&&(!val.equals("anyType{}"))){
                 customerName = val;
             }
             if(name.equals("CustomerContact")&&(!val.equals("anyType{}"))){
                 customerContact = val;
             }
             if(name.equals("CustomerAddress")&&(!val.equals("anyType{}"))){
                 customerAddress = val;
             }
             if(name.equals("CustomerEmail")&&(!val.equals("anyType{}"))){
                 customerEmail = val;
             }
             if(name.equals("PickupStatusId")&&(!val.equals("anyType{}"))){
                 pickupStatusId = Integer.parseInt(val);
             }
             if(name.equals("PickupId")&&(!val.equals("anyType{}"))){
                 pickupId = Integer.parseInt(val);
             }
             if(name.equals("PickupDate")&&(!val.equals("anyType{}"))){
                 pickupDate = val;
             }
             if(name.equals("PickupPendingSince")&&(!val.equals("anyType{}"))){
                 pickupPendingSince = val;
             }
               CustomerInfo customer = new CustomerInfo();
               customer.setCustomerAddress(customerAddress);
               customer.setCustomerAccode(customerAccode);
               customer.setCustomerContact(customerContact);
               customer.setCustomerEmail(customerEmail);
               customer.setCustomerName(customerName);
               customer.setPickupDate(pickupDate);
               customer.setPickupExecutive(pickupExecutive);
               customer.setPickupExecutiveId(pickupExecutiveId);
               customer.setPickupId(pickupId);
               customer.setPickupPendingSince(pickupPendingSince);
               customer.setPickupPriority(pickupPriority);
               customer.setPickupPriorityId(pickupPriorityId);
               customer.setPickupStatusId(pickupStatusId);
               customer.setStatus(0);
               customerArrayList.add(customer);
            }
            }

            SoapObject PickupItems = (SoapObject) Pickup.getProperty("PickupItems");

            for(int j=0; j<PickupItems.getPropertyCount(); j++){
            SoapObject PickupItem = (SoapObject) PickupItems.getProperty(j);

            for(int i=1; i<PickupItem.getPropertyCount(); i++){
                 PropertyInfo ppp = new PropertyInfo();
                 PickupItem.getPropertyInfo(i, ppp);
                 String names = ppp.name;
                 String value = PickupItem.getProperty(i).toString();

                 if(names.equalsIgnoreCase("CustomerCAFNo")&&(!value.equals("anyType{}"))){
                     customerCAFNo = value;
                 }
                 if(names.equalsIgnoreCase("ItemSerial")&&(!value.equals("anyType{}"))){
                     itemSerial = value;
                 }
                 if(names.equals("ItemType")&&(!value.equals("anyType{}"))){
                     itemType = value;
                 }
                 if(names.equals("ItemTypeId")&&(!value.equals("anyType{}"))){
                     itemTypeId = Integer.parseInt(value);
                 }
                 if(names.equals("ItemAction")&&(!value.equals("anyType{}"))){
                     itemAction = value;
                 }
                 if(names.equals("ItemActionId")&&(!value.equals("anyType{}"))){
                     itemActionId = Integer.parseInt(value);
                 }
                 if(names.equals("PickupDate")&&(!value.equals("anyType{}"))){
                     pickupDateItem = value;
                 }
                 if(names.equals("PickupId")&&(!value.equals("anyType{}"))){
                     pickupIdItem = Integer.parseInt(value);
                 }
                 if(names.equals("ItemRemark")&&(!value.equals("anyType{}"))){
                     itemRemark = value;
                 }
                 if(names.equals("IsValidItem")&&(!value.equals("anyType{}"))){
                     isValidItem = Boolean.parseBoolean(value);
                 }
                    Log.i(names, value);
                   PickupItem_Info item = new PickupItem_Info();
                   item.setIsValidItem(isValidItem);
                   item.setItemAction(itemAction);
                   item.setItemActionId(itemActionId);
                   item.setItemRemark(itemRemark);
                   item.setItemSerial(itemSerial);
                   item.setItemType(itemType);
                   item.setItemTypeId(itemTypeId);
                   item.setCustomerAcc(customerAccode);
                   item.setCustomerCAFNo(customerCAFNo);
                   item.setPickupDateItem(pickupDateItem);
                   item.setPickupIdItem(pickupIdItem);
                   item.setStatus(0);
                   pickupItemArraylist.add(item);
                }
                }
                }

我得到的一些值为null,它们存在于响应中但不存在于模型中。代码工作正常但我的实现中缺少某些东西。我第一次使用它。可能不适合使用它。

0 个答案:

没有答案