Search code examples
androidweb-servicesxml-serializationandroid-ksoap2arrays

How to pass a String array to a webservice using soap libraries?


I need to pass a a string array to a predefined webserivce designed to accept an array of string values. However when I create a soap envelope and set array.class or string.class properties to the request it throws a serialization error.

Any suggestions for the above? What should be the suggested data type or method to work around the same.

 SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);

    PropertyInfo p1 = new PropertyInfo();
    p1.setName("items");
    p1.setValue(results);
    p1.setType(String.class); // else Array.class.
    request.addProperty(p1);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    envelope.dotNet = true;

        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        httpTransport.debug = true;
        httpTransport.call(SOAP_ACTION, envelope);
                       // throws an error in the above.

        result = httpTransport.responseDump;

Solution

  • It is a known issue with the KSOAP2 for Android library, which at the moment simply doesn't support arrays. The issue description is here.

    A third-party patch, solution and an example can be found here.

    Look on these link, You can find your answer on that.