title: Don't receive nested XML nodes from SOAP Web Service using ksoap2
body: <p>ciao everybody,
  I am becoming stupid about this question. I hope someone can help me!! 
  I searched in the web for a solution, but everiting I found doesn't work for me. This is the scenario:
  I am trying to make a request to a .net ws. The request is simple, but the response is the nested 2 level XML structure that follows:</p>
  
  <pre><code>&lt;soap:Body&gt;
      &lt;ProgettoResponse xmlns="http://tempuri.org/"&gt;
        &lt;ProgettoResult xmlns=""&gt;
          &lt;Success&gt;boolean&lt;/Success&gt;
          &lt;Message&gt;string&lt;/Message&gt;
          &lt;Progetto&gt;
            &lt;Titolo&gt;string&lt;/Titolo&gt;
            &lt;Descrizione&gt;string&lt;/Descrizione&gt;
          &lt;/Progetto&gt;
        &lt;/ProgettoResult&gt;
      &lt;/ProgettoResponse&gt;
    &lt;/soap:Body&gt;
  </code></pre>
  
  <p>but the response I receive from WS is always: 
      anyType {Success=true; Message=OK; Progetto=anyType{};}</p>
  
  <p>this situation is confirmed by logcat</p>
  
  <p>The  node is always empty. Obviusly I am shure that the WS, invoked with the same parameters sends a complete structure (via a web application and via ad app i-phone).</p>
  
  <p>I am using ksoap2-android-assembly-2.6.0-jar-with-dependencies in android 2.1  / 2.2 environment.</p>
  
  <p>This is the class that I use to invoke ws:</p>
  
  <pre><code>package feronia.culturando.android;
  
  import org.ksoap2.SoapEnvelope;
  import org.ksoap2.serialization.PropertyInfo;
  import org.ksoap2.serialization.SoapObject;
  import org.ksoap2.serialization.SoapSerializationEnvelope;
  import org.ksoap2.transport.HttpTransportSE;
  
  
  public class webService 
  {
      public final String SOAP_ACTION = "http://tempuri.org/Progetto";
  public  final String METHOD_NAME = "Progetto"; 
  public  final String NAMESPACE = "http://tempuri.org/";
  public  final String URL = "http://www.feronia.it/intra/webservice/wsCulturando.asmx";
  
      public webService() 
      { 
      }
  
      public String Call(String a,int b)
      {
              SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
              PropertyInfo pi=new PropertyInfo();
                              pi.setName("a");
                      pi.setValue(a);
                      pi.setType(String.class);
                      request.addProperty(pi);
                      pi=new PropertyInfo();
                      pi.setName("b");
                      pi.setValue(b);
                      pi.setType(Integer.class);
                      request.addProperty(pi);
  
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
              SoapEnvelope.VER11);
  
              envelope.dotNet = true;         
              envelope.setOutputSoapObject(request);
  
              envelope.addMapping(NAMESPACE, "ProgettoResult", new ProgettoResult().getClass());
              envelope.addMapping(NAMESPACE, "Progetto", new Progetto().getClass());
  
  
              HttpTransportSE httpTransport = new HttpTransportSE(URL);
              SoapObject response=null;
  
              String totalCount = "";
              try
              {
                      httpTransport.call(SOAP_ACTION, envelope);
  
                      response = (SoapObject)envelope.getResponse();
                      //totalCount = response.getPropertyAsString("Progetto").toString();     
                      //totalCount = response.toString();
                      //Progetto prog = response.getProgetto();
                      totalCount =  response.toString();
                      ////////////Progetto prog = (Progetto) response.getProperty(3);
                      //////////////totalCount = prog.toString();
              }
              catch (Exception e)
              {
                       e.printStackTrace();
              }
  
  
              //String totalCount = response.getProperty("Success").toString();
              //Object totalCount = response.getProperty(Progetto.class);
  
  
  
              //Object resultData = (SoapObject)response.getProperty(2);
  
              return "risposta dal WS = " + totalCount;
      }
  
  
  }
  </code></pre>
  
  <p>and these are the classes for ProgettoResult and Progetto</p>
  
  <pre><code>package feronia.culturando.android;
  
  import java.util.Hashtable;
  
  import org.ksoap2.serialization.KvmSerializable;
  import org.ksoap2.serialization.PropertyInfo;
  
  public class ProgettoResult implements KvmSerializable {
  
  
      private String          pSuccess;
      private String          pMessage;
      private Progetto        pProgetto;
  
      public Progetto getProgetto()
      {
              return pProgetto;
      }
  
      public void setProgetto(Progetto Progetto)
      {
              this.pProgetto = Progetto;
      }
  
      public ProgettoResult()
      {
              this.setSuccess("");
              this.setMessage("");
      }
  
      public ProgettoResult(String Success, String Message)
      {
              this.setSuccess(Success);
              this.setMessage(Message);
      }
  
      public Object getProperty(int arg0)
      {
              switch(arg0)
              {
              case 0:
                      return this.getSuccess();
              case 1:
                      return this.getMessage();
              case 2:
                      return this.getProgetto();
              }
              return null;
      }
  
  
      public int getPropertyCount()
      {
              return 3;
      }
  
      public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) 
      {
              switch(index)
              {
              case 0:
                      info.name="Success";
                      info.type=PropertyInfo.STRING_CLASS;
                      break;
              case 1:
                      info.name="Message";
                      info.type=PropertyInfo.STRING_CLASS;
                      break;
              case 2:
                      info.name="Progetto";
                      info.type=Progetto.class;
                      break;
              default:
                      break;
              }
      }
  
  
      public void setProperty(int index, Object value) 
      {
              switch(index)
              {
              case 0:
                      this.setSuccess(value.toString());
                      break;
              case 1:
                      this.setMessage(value.toString());
                      break;
              case 2:
                      this.setProgetto((Progetto)value);
                      break;
              default:
                      break;
              }
      }
      /*********** GET - SET   *****************/
  
      public void setSuccess(String Success)
      {
              this.pSuccess = Success;
      }
  
      public String getSuccess()
      {
              return pSuccess;
      }
  
      public void setMessage(String Message)
      {
              this.pMessage = Message;
      }
  
      public String getMessage()
      {
              return pMessage;
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>package feronia.culturando.android;
  
  import java.util.Hashtable;
  
  import org.ksoap2.serialization.KvmSerializable;
  import org.ksoap2.serialization.PropertyInfo;
  
  public class Progetto implements KvmSerializable{
  
      private String pTitolo;
      private String pDescrizione;
  
      public Progetto()
      {
              this.setTitolo("");
              this.setDescrizione("");
      }
  
      public Progetto(String t,String d)
      {
              this.setTitolo(t);
              this.setDescrizione(d);
      }
  
      public Object getProperty(int index) 
      {
              switch(index)
              {
              case 0:
                      return this.getTitolo();
              case 1:
                      return this.getDescrizione();
              }
              return null;
      }
  
  
      public int getPropertyCount() 
      {
              return 2;
      }
  
  
      public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) 
      {
              switch(index)
              {
              case 0:
                      info.name="Titolo";
                      info.type=PropertyInfo.STRING_CLASS;
                      break;
              case 1:
                      info.name="Descrizione";
                      info.type=PropertyInfo.STRING_CLASS;
                      break;
              default: 
                      break;
              }
      }
  
  
      public void setProperty(int index, Object value) 
      {
              switch(index)
              {
              case 0:
                      this.setTitolo(value.toString());
                      break;
              case 1:
                      this.setDescrizione(value.toString());
                      break;
              default: 
                      break;
              }
      }
  
      /*********** GET - SET   *****************/
  
      public void setTitolo(String Titolo)
      {
              this.pTitolo = Titolo;
      }
  
  
      public String getTitolo()
      {
              return pTitolo;
      }
  
      public void setDescrizione(String Descrizione)
      {
              this.pDescrizione = Descrizione;
      }
  
      public String getDescrizione()
      {
              return pDescrizione;
      }
  }
  </code></pre>
  
  <p>is there anybody who can tell me where is the mistake???  Please help me if You can!!!</p>
  
  <p>================================================================================</p>
  
  <p>thank You very much himanshu and shadesco for your interest to my question!! here is the code of my activity class where is the calling funcion.
  string a of the calling is not significant in this moment (not yet implemented the controls upon it: I pass a not significant string), while int b is simply che code of the project (progetto = 2) whose data are requested to web service. </p>
  
  <p>the request:</p>
  
  <pre><code>&lt;soap:Body&gt;
      &lt;Progetto xmlns="http://tempuri.org/"&gt;
        &lt;Guid&gt;string&lt;/Guid&gt;
        &lt;Id_Progetto&gt;int&lt;/Id_Progetto&gt;
      &lt;/Progetto&gt;
  &lt;/soap:Body&gt;
  </code></pre>
  
  <p>the code of the calling class: consider that I can see correctly the (wrong) response on the emulator</p>
  
  <pre><code>package feronia.culturando.android;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.text.Html;
  import android.widget.TextView;
  
  public class Presentazione extends Activity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.presentazione);
  
  
      webService cs=new webService();
  
      String appo=cs.Call("oi", 2);
  
      TextView pres_prog = (TextView) findViewById(R.id.pres_prog);
  
      pres_prog.setText(Html.fromHtml(appo));
  }
  
  }
  </code></pre>
  
  <p>I don't believe it is important, but the complete response of the method is:</p>
  
  <pre><code>&lt;soap:Body&gt;
  &lt;ProgettoResponse xmlns="http://tempuri.org/"&gt;
    &lt;ProgettoResult xmlns=""&gt;
      &lt;Success&gt;boolean&lt;/Success&gt;
      &lt;Message&gt;string&lt;/Message&gt;
      &lt;Progetto&gt;
        &lt;Titolo&gt;string&lt;/Titolo&gt;
        &lt;Descrizione&gt;string&lt;/Descrizione&gt;
        &lt;Immagini&gt;
          &lt;Immagine xsi:nil="true" /&gt;
          &lt;Immagine xsi:nil="true" /&gt;
        &lt;/Immagini&gt;
      &lt;/Progetto&gt;
    &lt;/ProgettoResult&gt;
  &lt;/ProgettoResponse&gt;
  </code></pre>
  
  <p></p>
  
  <p>there is another block 
       
  but requesting progetto = 2 this section of the response is not present (the project has no images associated and the tag </p>
  
  <pre><code>&lt;Immagini /&gt; 
  </code></pre>
  
  <p>is not generated. I am trying to go on step by step...</p>