title: KSOAP 2 with complex objects
body: <p>I have a problem with KSOAP2 for android with dependencies on an Android device.</p>
  
  <p>I followed the instruction  from seesharpgears <a href="http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html" rel="nofollow">http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html</a></p>
  
  <p>I have a Embarcadero C++ Builder XE2 Server with this function to pass a complex data type.</p>
  
  <p>The function is this:</p>
  
  <p>I tried to create a dummy method witch returns back his request.</p>
  
  <p>I created a class called Category.</p>
  
  <p>But I don't know why, I am receiving still this data with data type vector:</p>
  
  <p>Here my code:</p>
  
  <pre><code>public void getSettings(String sessionId){
   SoapObject Request = new SoapObject(ProgramSettings.NAMESPACE, "GetCategoryById");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = false;
    envelope.setOutputSoapObject(Request);
    Category C = new Category();
    envelope.addMapping("urn:@:TrackNavMobile", "Category",new Category().getClass());
   // addMapping("urn:@:TrackNavMobile", "Category", cat.getClass());
    String url="http://" + readIp() + ":" + readPort() +"/soap/ITrackNavMobile";
    HttpTransportSE  androidHttpTransport = new HttpTransportSE(url);
    /*
     * Call the web service and retrieve result ... how luvly &lt;3
     * 
     * */
    try
    {
        androidHttpTransport.call(ProgramSettings.SOAP_ACTION, envelope);
        SoapObject response = (SoapObject)envelope.bodyIn;
  
        //TextView tv = (TextView)findViewById(R.id.textView1);
  
           for(int i=0;i&lt;response.getPropertyCount();i++)
     {
               new AlertDialog.Builder(this) 
               .setMessage(response.getProperty(0).toString())
               .setNeutralButton("OKi", null)
               .show();
  
        //if complex type is present then you can cast this to SoapObject and if primitive type is returned you can use toString() to get actuall value.
     }
  
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
  }    
  </code></pre>
  
  <p>This is the result with properties...When I am debugging it calls the setCategory method written in Java with the correct values...but it doesn't return them.. 
  [Category : it.comtec.Category@44f02ea0, return : it.comtec.Category@44f02ea0]</p>
  
  <p>This is my server dummy method witch is called:</p>
  
  <pre><code> Category*  TTrackNavMobileImpl::GetCategoryById(){
          Category* setup= new Category();
          setup-&gt;Name="Thomas";
          setup-&gt;CategoryId=1;
          setup-&gt;Description="Test1";
          return setup;
   } 
  </code></pre>
  
  <p>This is the RequestDump:</p>
  
  <pre><code>&lt;v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:d="http://www.w3.org/2001/XMLSchema" 
   xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"   
   xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;v:Header /&gt;
    &lt;v:Body&gt;
      &lt;n0:GetCategoryById id="o0" c:root="1"    
       sessionId="FFEF196A3940136D7C141C4F01965D7D" 
       xmlns:n0="http://tempuri.org/" /&gt;
    &lt;/v:Body&gt;
  &lt;/v:Envelope&gt;
  </code></pre>
  
  <p>And this is the ResponseDump:</p>
  
  <pre><code> &lt;?xml version="1.0"?&gt;
     &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"   
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"&gt;
     &lt;SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"   
      xmlns:NS1="urn:TrackNavMobile-ITrackNavMobile"&gt;
      &lt;NS1:GetCategoryByIdResponse xmlns:NS2="urn:@:TrackNavMobile"&gt;
       &lt;NS2:Category id="1" xsi:type="NS2:Category"&gt;
         &lt;Name xsi:type="xsd:string"&gt;Thomas&lt;/Name&gt;
         &lt;Description xsi:type="xsd:string"&gt;Test1&lt;/Description&gt;
         &lt;CategoryId xsi:type="xsd:int"&gt;1&lt;/CategoryId&gt;
        &lt;/NS2:Category&gt;&lt;return href="#1"/&gt; 
      &lt;/NS1:GetCategoryByIdResponse&gt;
    &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>Someone has an Idea?</p>