Android Ksoap2 cannot serialize Array of int

32 Views Asked by At

I'm having a problem trying to send an object which contains array of int to .net web service.

Here my XML

      <Token>string</Token>
      <Type>string</Type>
      <DownloadSelectionInfo>
        <filesListCount>int</filesListCount>
        <filesList>
          <int>int</int>
          <int>int</int>
        </filesList>
        <Filename>string</Filename>
      </DownloadSelectionInfo>

Here my Serializable class

public class DownloadSelectionInfo implements KvmSerializable {
    ....
    private ArrayList<Integer> filesList;
    ...
    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
          ...
            case 1:
                info.type = PropertyInfo.VECTOR_CLASS;;
                info.name = "filesList";
                break;
         ...
    }

    public void setProperty(int index, Object value) {
              ....
            case 1:
                filesList.add(Integer.parseInt(value.toString()));
            .....
    }
}

Here webservice call


 //add filesList
 SoapObject soFilesList = new SoapObject(Util.getWebService(),"filesList");
 for(Integer i : downloadSelectionInfo.getFilesList()){
     soFilesList.addProperty("int",i);
 }
 soDownloadSelectionInfo.addSoapObject(soFilesList);

 PropertyInfo pi = new PropertyInfo();
 pi.setName("DownloadSelectionInfo");
 pi.setValue(downloadSelectionInfo);
 pi.setType(DownloadSelectionInfo.class);
 Request.addProperty(pi);

 soapEnvelope.addMapping(Util.getWebService(), "DownloadSelectionInfo",DownloadSelectionInfo.class);

But I get error "java.lang.RuntimeException: Cannot serialize [10,9,1]". Any help please?

1

There are 1 best solutions below

2
D.Djaber On

I have found the solution :

add soapEnvelope.addMapping(Util.getWebServiceGed(), "filesList", Vector.class);

and change arrayList< Integer > to Vector< Integer >