How to send ListT with KvmSerializable?

0

I'm implementing KvmSerializable for communication with webservice with complex types.

I have a List property. But I'm indicating the type List.class and that list is not getting there in the webservice.

What am I doing wrong?

public class CadastrosImpGarIn implements KvmSerializable {

public int codCli;
public int codEmp;
public int codFil;
public int codMot;
public String datCol;
public String flowInstanceID;
public String flowName;
public String numDoc;
public List<CadastrosImpGarInTabBat> tabBat;

@Override
public Object getProperty(int index) {
    switch (index) {
    case 0:
        return codCli;
    case 1:
        return codEmp;
    case 2:
        return codFil;
    case 3:
        return codMot;
    case 4:
        return datCol;
    case 5:
        return flowInstanceID;
    case 6:
        return flowName;
    case 7:
        return numDoc;
    case 8:
        return tabBat;
    default:
        return null;
    }
}

@Override
public int getPropertyCount() {
    return 8;
}

@SuppressWarnings("rawtypes")
@Override
public void getPropertyInfo(int index, Hashtable hash, PropertyInfo info) {
    switch (index) {
    case 0:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "codCli";
        break;
    case 1:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "codEmp";
        break;          
    case 2:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "codFil";
        break;
    case 3:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "codMot";
        break;
    case 4:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "datCol";
        break;
    case 5:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "flowInstanceID";
        break;
    case 6:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "flowName";
        break;
    case 7:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "numDoc";
        break;
    case 8:
        info.type = List.class;
        info.name = "tabBat";
        break;
    default:
        break;
    }
}

@SuppressWarnings("unchecked")
@Override
public void setProperty(int index, Object value) {
    switch (index) {
    case 0:
        codCli = Integer.parseInt(value.toString());
        break;
    case 1:
        codEmp = Integer.parseInt(value.toString());
        break;
    case 2:
        codFil = Integer.parseInt(value.toString());
        break;
    case 3:
        codMot = Integer.parseInt(value.toString());
        break;
    case 4:
        datCol = value.toString();
        break;
    case 5:
        flowInstanceID = value.toString();
        break;
    case 6:
        flowName = value.toString();
        break;
    case 7:
        numDoc = value.toString();
        break;
    //TODO List?        
    case 8:
        tabBat = (List<CadastrosImpGarInTabBat>) value;
        break;
    default:
        break;
    }
}

}

    
asked by anonymous 18.06.2014 / 19:55

1 answer

0

I ended up creating the "nail" code using SoapObject

    SoapObject coletaEnv = new SoapObject();
    coletaEnv.addProperty("codCli", coleta.getIdCliente());
    coletaEnv.addProperty("codEmp", 1);
    coletaEnv.addProperty("codFil", 1);
    coletaEnv.addProperty("codMot", coleta.getIdMotorista());
    coletaEnv.addProperty("datCol", DateUtils.dateToString(coleta.getDataHora()));
    coletaEnv.addProperty("numDoc", coleta.getProtocolo());

    for (ColetaItem item : coleta.getBaterias()) {

        SoapObject tabBat = new SoapObject(null, "tabBat");
        tabBat.addProperty("codBar", item.getCodigoBarras());
        tabBat.addProperty("codRef", item.getBateria().getReferencia());
        tabBat.addProperty("datFab", DateUtils.dateToString(item.getDataFabricacao()));
        tabBat.addProperty("datVct", DateUtils.dateToString(item.getDataVencimento()));
        tabBat.addProperty("defOri", item.getDefeito().getDescricao());
        tabBat.addProperty("desDef", item.getDefeito().getDescricao());
        coletaEnv.addSoapObject(tabBat);
    }

    String methodName = "ImpGar";

    SoapObject request = new SoapObject(WSBase.NAMESPACE, methodName);
    request.addProperty("user", "user");
    request.addProperty("password", "pass");
    request.addProperty("encryption", 0);

    PropertyInfo pi = new PropertyInfo();
    pi.setName("parameters");
    pi.setValue(coletaEnv);
    request.addProperty(pi);
    
01.07.2014 / 17:40