Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Provided that the SOAP response is in a valid JSON format; the accepted answer may not always be successful, as the the response string does not start with "{" but with "anyType". </p> <p>In this case, I always got an error regarding "anyType" not being a valid JSON Object. I then proceeded to substring the response string with the IndexOf("{"); and this then started the parsing, though again if the response string is not a valid JSON format, it will break.</p> <p>The issue here was that my response string had un-escaped characters which did not play nicely with the JSON formatting.</p> <p>With reference to this answer: <a href="https://stackoverflow.com/questions/6493762/android-ksoap2-how-to-get-property-name">Android KSoap2: how to get property name</a></p> <p>this is what I managed to implement:</p> <pre><code> public Bundle getElementsFromSOAP(SoapObject so){ Bundle resultBundle = new Bundle(); String Key = null; String Value = null; int elementCount = so.getPropertyCount(); for(int i = 0;i&lt;elementCount;i++){ PropertyInfo pi = new PropertyInfo(); SoapObject nestedSO = (SoapObject)so.getProperty(i); int nestedElementCount = nestedSO.getPropertyCount(); Log.i(tag, Integer.toString(nestedElementCount)); for(int ii = 0;ii&lt;nestedElementCount;ii++){ nestedSO.getPropertyInfo(ii, pi); resultBundle.putString(pi.name, pi.getValue().toString()); //Log.i(tag,pi.getName() + " " + pii.getProperty(ii).toString()); //Log.i(tag,pi.getName() + ": " + pi.getValue()); } } return resultBundle; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload