title: Parse data from SOAP response in Android
body: <p>I have the following soap output:</p>
  
  <pre><code>tabResponse
  {
    tabResult=anyType
   {
     schema=anyType
    {
      element=anyType
       {complexType=anyType
         {
          choice=anyType
         {
           element=anyType
          {
          complexType=anyType
           {
           sequence=anyType
           {
           element=anyType{};
           element=anyType{};
             element=anyType{}; 
            element=anyType{};
                };
               }; 
             };
             };
                };
                 };
                };
            diffgram=anyType
            {
            DocumentElement=anyType
           {sh=anyType
              {SchoolName=Bialik Hebrew Day School; SchoolType=Public elementary;  SchoolGrade=JK-12; City=Toronto; 
            };
            sh=anyType
            {SchoolName=Millwood Junior School; SchoolType=Public elementary;  SchoolGrade=JK-12; City=Toronto; 
             };
            sh=anyType
             {SchoolName=Dovercourt Junior Public School; SchoolType=Public elementary;  SchoolGrade=JK-12; City=Toronto;
             };
            sh=anyType{
             SchoolName=John English Junior Middle School; SchoolType=Public elementary;  SchoolGrade=JK-12; City=Toronto;
             };
           sh=anyType
           {SchoolName=Ossington Old Orchard Public School; SchoolType=Public elementary;  SchoolGrade=JK-12; City=Toronto; 
             };
             };
              };
              };
             }
  </code></pre>
  
  <p>And my code is like this:</p>
  
  <pre><code>SoapDemoActivity.java
  
  public class SoapDemoActivity extends Activity {
  
  private final String NAMESPACE = "****";
  private final String URL = "*******";
  private final String SOAP_ACTION_1 = "********";
  private final String SOAP_ACTION_5 = "*******";
  private final String METHOD_NAME_5 = "******";
  Button mButtonTab;
  TextView mTextViewResult;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
        mButtonTab=(Button)findViewById(R.id.button5);
        mButtonTab.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              getDataTable(NAMESPACE,METHOD_NAME_5,SOAP_ACTION_5,URL);
  
          }
      });
   }
    public void getDataTable(String NAMESPACE, String METHOD_NAME,
          String SOAP_ACTION, String URL) {
      // TODO Auto-generated method stub
      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
  
      request.addProperty("uid","29");
  
  
      SoapSerializationEnvelope envelope = new      SoapSerializationEnvelope(SoapEnvelope.VER11);
      envelope.dotNet = true;
      envelope.setOutputSoapObject(request);
      HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
  
      try {
          androidHttpTransport.call(SOAP_ACTION, envelope);
          SoapObject response = (SoapObject)envelope.bodyIn;
  
  
          if(response != null)
          {
  
              SoapObject tabResponse = (SoapObject) response.getProperty(0);
  
              SoapObject tabResult = (SoapObject) tabResponse .getProperty(0);
              SoapObject schmea = (SoapObject) tabResult .getProperty(0);
              SoapObject elmemnt = (SoapObject) schmea .getProperty(0);
              SoapObject complextype = (SoapObject) elmemnt .getProperty(0);
              SoapObject choise = (SoapObject) complextype  .getProperty(0);
              SoapObject element_1 = (SoapObject) choise .getProperty(0);
              SoapObject complextype_1 = (SoapObject) element_1 .getProperty(0);
              SoapObject sequence = (SoapObject) complextype_1 .getProperty(0);
              SoapObject element_2 = (SoapObject) sequence .getProperty(0);
              SoapObject element_3 = (SoapObject) element_2 .getProperty(0);
              SoapObject element_4 = (SoapObject) element_3 .getProperty(0);
              SoapObject element_5 = (SoapObject) element_4 .getProperty(0);
              SoapObject diffgram = (SoapObject) element_5 .getProperty(0);
              SoapObject documentelement = (SoapObject) diffgram .getProperty(0);
              for(int i=0;i&lt;documentelement.getPropertyCount();i++) 
              {
                  SoapObject getAllData = (SoapObject) documentelement.getProperty(i);
                  if (getAllData instanceof SoapObject) {
                      String data= getAllData.getProperty("sh").toString();
                      System.out.println("DATA "+data);
  
                  }
              }
  
          }
  
          Object re= null;
          re = envelope.getResponse();
          Log.i("myApp", response.toString());
  
          System.out.println("dfdsfd "+re.toString());
          mTextViewResult.setText(re.toString());
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
  }
  
   }
  </code></pre>
  
  <p>I get an error message like:</p>
  
  <pre><code>10-02 03:39:26.892: W/System.err(1284): java.lang.ArrayIndexOutOfBoundsException:   length=0; index=0
  10-02 03:39:26.892: W/System.err(1284):     at  java.util.Vector.arrayIndexOutOfBoundsException(Vector.java:907)
  10-02 03:39:26.892: W/System.err(1284):     at java.util.Vector.elementAt(Vector.java:328)
  10-02 03:39:26.892: W/System.err(1284):     at org.ksoap2.serialization.SoapObject.getProperty(SoapObject.java:139)
  10-02 03:39:26.892: W/System.err(1284):     at com.demosoap.SoapDemoActivity.getDataTable(SoapDemoActivity.java:241)
  10-02 03:39:26.900: W/System.err(1284):     at com.demosoap.SoapDemoActivity$5.onClick(SoapDemoActivity.java:134)
  </code></pre>
  
  <p>This message give at line in my java file at</p>
  
  <pre><code>    SoapObject element_2 = (SoapObject) sequence .getProperty(0);
  </code></pre>
  
  <p>How can I parse this correctly?</p>