Serialize an array of ints to send using KSOAP2

后端 未结 7 1482
借酒劲吻你
借酒劲吻你 2021-01-06 01:41

I\'m having a problem trying to send an array of ints to a .NET web service which expects an array in one of the arguments. That\'s at least what I understand from the API d

7条回答
  •  无人及你
    2021-01-06 02:24

    Here is nice example that might help you:

    http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks

    Here is my quick fix to this issue:

    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
    
    SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
    soapEnvelope.setOutputSoapObject(Request);
    soapEnvelope.dotNet = true;
    
    
    List companies =  new ArrayList();
    companies.add(65);
    companies.add(66);
    companies.add(67);
    
    Request.addProperty("name", "test1");
    SoapObject soapCompanies = new SoapObject(NAMESPACE, "companies");
    for (Integer i : companies){
        soapCompanies.addProperty("int", i);
    }
    Request.addSoapObject(soapCompanies);
    

    Output XML:

    
                65
                66
                67
    
    test1
    

提交回复
热议问题