0

I am using trying to get the name of a SoapObject property into a string. The SoapObject object:

anyType{ChassisReceiving=true;
JobOrderIssuing=true; 
MfgOrderReducing=true; 
PartsOrdering=true; 
PhysicalInventoryTaking=true; 
PurchaseOrderReceiving=true; 
SalesOrderReducing=true; }

which is expected. However, I am trying to just get the property name (i.e. ChassisReceiving, JobOrderIssuing, etc.). I am trying to use: String name = response.getProperty(i).toString(); but mod comes back as true. Full code:

SoapObject response = (SoapObject) webService.getResponse();
                for (int i=0; i <= response.getPropertyCount()-1; i++) {
                    boolean modAllowed = Boolean.parseBoolean(response.getProperty(i).toString());
                    if (modAllowed) {
                        String mod = response.getProperty(i).toString();
                        switch (mod) {
                            case "ChassisReceiving":
                                mod = "Chassis Receiving";
                                break;
                            case "JobOrderIssuing":
                                mod = "Job Order Issuing";
                                break;
                            //add case for each property name
                        }
                        AddModule(response, mod);
                    }
                }

So far nothing I've tried results in mod coming back as anything other than true. Any ideas?

Thanks!

Patrick Davis
  • 101
  • 1
  • 11

2 Answers2

0

I feel stupid. Got it working from this: Android KSoap2: how to get property name

Essentially added: PropertyInfo propertyInfo = new PropertyInfo(); Then in the for loop: response.getPropertyInfo(i, propertyInfo); String mod = propertyInfo.getName();

Works as expected.

Patrick Davis
  • 101
  • 1
  • 11
0

your answer : https://stackoverflow.com/a/6908752/8357735

Where you loop trough your response you can get access to the PropertyInfo from the different properties. I used the following setup to get the names of the parameters and the values that go with them:

//Inside your for loop
PropertyInfo pi = new PropertyInfo();
resSoap.getPropertyInfo(i, pi);
Log.d(TAG, pi.name + " : " + resSoap.getProperty(i).toString());

This creates a PropertyInfo object, adds the information from the property in that object and then gives you access to all this information. And then prints it to your LogCat in the following format.

<PropertyName> : <PropertyValue>
Geert Smelt
  • 987
  • 1
  • 7
  • 19
farid
  • 300
  • 1
  • 8