Passing Complex Object as parameter in KSOAP2
<p>I want to pass an array of integer values to a sorting webservice by using ksoap. My application runs successfully when tested on the server side. However, the client program blocks after calling the method "androidHttpTransport.call(SOAP_ACTION, envelope)". Can anybody guide me what I am doing wrong. Thanks   </p>

<p>Find below my code for the android application:</p>

<pre><code>public void onClick(View arg0) {
         try {
             KVMInterface ob=new KVMInterface();    
             PropertyInfo pi = new PropertyInfo();
                pi.setName("ob");
                pi.setValue(ob);
                pi.setType(ob.getClass());
              METHOD_NAME = "Sort";  
              SOAP_ACTION = NAMESPACE+METHOD_NAME;

             SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);            
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet = true;
               request.addProperty(pi);
                envelope.setOutputSoapObject(request);
                envelope.addMapping(NAMESPACE, "ob",new KVMInterface().getClass());

                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

                androidHttpTransport.call(SOAP_ACTION, envelope);
                SoapObject response = (SoapObject)envelope.getResponse();
                System.out.println("Response Received");
                                 SoapObject  ks = ( SoapObject ) envelope.bodyIn; 
                ob=(KVMInterface) ks.getProperty(0);
                System.out.println(ob);
</code></pre>

<p>Where the KVMInterface class on the client is as follows:</p>

<pre><code>public class KVMInterface implements KvmSerializable
{
public int [] a=new int[5]; 
public KVMInterface()
{
            initialize();
    }

@Override
public Object getProperty(int arg0) {
    // TODO Auto-generated method stub
    return a;
}

@Override
public int getPropertyCount() {
    // TODO Auto-generated method stub
    return 1;
}

@Override
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
    // TODO Auto-generated method stub
    arg2.type=PropertyInfo.INTEGER_CLASS;
    arg2.name="Array";
}

@Override
public void setProperty(int arg0, Object arg1) {
    // TODO Auto-generated method stub

}
private void initialize()
{
for(int i=0;i&lt;a.length;i++) 
    a[i]=i;
}
</code></pre>

<p>}</p>

<p>The following is the code for Sort mothod on the webserver application</p>

<p>[WebMethod (EnableSession = true)]  </p>

<pre><code>    public KVMInterface Sort(KVMInterface ob)
    {
         Random random = new Random();

         for (int i = 0; i &lt; a.Length; i++)
         {
             a[i] = random.Next(1, a.Length);
             }
        KVMInterface obkvm = (KVMInterface)ob;
        int temp = 0;

        for (int i = 0; i &lt; obkvm.a.Length; i++)
        {
            for (int j = i + 1; j &lt; obkvm.a.Length; j++)
            {
                if (obkvm.a[i] &gt; obkvm.a[j])
                {
                    temp = obkvm.a[i];
                    obkvm.a[i] = obkvm.a[j];
                    obkvm.a[j] = temp;
                }
            }

        }
        return ob;
    }

public class KVMInterface
    {
        public int[] a = new int[5];

        public KVMInterface()
        {
            intialize();
        }
        void intialize()
        {
            for (int i = 0; i &lt; a.Length; i++)
            {
                a[i] = i;
            }
        }
    }
</code></pre>
