title: How can I parse anyType {----} response with ksoap2
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3092424/parsing-ksoap2-response">Parsing ksoap2 response</a>  </p>
  </blockquote>
  
  
  
  <p>I have seen many forum questions about this, but i haven't found a solution that works for me. 
  THis is my code: </p>
  
  <pre><code>String serviceURL = "http://www.mywebsite.com/WebService.asmx";
                   String serviceNamespace = "http://tempuri.org/";
                   String serviceMethod = "getUser";
                   String SoapAction = "http://tempuri.org/getUser";
                   SoapObject SoapObj = new SoapObject(serviceNamespace,serviceMethod);
                      SoapObj.newInstance ();
                      SoapObj.addProperty ("uname", "Evv");
                     // SoapObj.addProperty ("uposy", "333");
                      //SoapObj.addProperty ("uposx", "333");                 
                      SoapSerializationEnvelope envelope = new                        SoapSerializationEnvelope(SoapEnvelope.VER11);
                   envelope.bodyOut = SoapObj;
                   envelope.dotNet = true;
                   envelope.implicitTypes = true;
                   envelope.encodingStyle = "utf-8";
                   envelope.enc = SoapSerializationEnvelope.ENC2001;
                   envelope.xsd = SoapEnvelope.XSD;
                   envelope.xsi = SoapEnvelope.XSI;
                   AndroidHttpTransport ht = new AndroidHttpTransport(serviceURL);
                   //Initiate Connection
  
  
                   try 
                    {
                    ht.debug = true;
                    ht.call (SoapAction, envelope);
                     SoapObject response=(SoapObject)envelope.getResponse();
                        tv.setText(response);
  </code></pre>
  
  <p>}</p>
  
  <p>Is the anyType{uposx=222; uposy=222;} a JSON-response? I can see it written out in the textview, but i want to parse it. </p>
  
  <p>I have tried with JSON Object, but not gotten it to work:</p>
  
  <pre><code> JSONObject JSONObj;
                    JSONArray JSONArr;
                     SoapObject res = (SoapObject)envelope.getResponse();
                     gets our result in JSON String
                    String ResultObject = response.getProperty(0).toString();
  
                    if (ResultObject.startsWith("anyType{")) { // if JSON string is an object
                        JSONObj = new JSONObject(ResultObject);
  
     Iterator&lt;String&gt; itr = JSONObj.keys();
                        while (itr.hasNext()) {
                            String Key = (String) itr.next();
                            String Value = JSONObj.getString(Key);
                            bundleResult.putString(Key, Value);
                            tv.setText(bundleResult.getString(Key));
  
                        }
                    } else if (ResultObject.startsWith("anyType{")) { // if JSON string is an array
                        JSONArr = new JSONArray(ResultObject);
                        tv.setText("length" + JSONArr.length());
                        for (int i = 0; i &lt; JSONArr.length(); i++) {
                            JSONObj = (JSONObject) JSONArr.get(i);
                            bundleResult.putString(String.valueOf(i), JSONObj.toString());
                            // System.out.println(bundleResult.getString(i));
                        } 
                    }
  </code></pre>
  
  <p>Thanks for any help! </p>