Ksoap2 casting getResponse ()

Calling the .net SOAP1.1 web service from android using ksoap2 lib. I ran into the problem of responding to an arbitrary object. For example, the code below is called correct after httpTransport.call (soapAction, soapEnvelope); and there is data inside. But I can not attribute it to a specific object neither to SoapObject nor to Vector, as I saw in several examples, I get a CastException or just nothing. If someone knows how to deal with this, please help.

public StatusSetting[] GetAllStatuses(String installation){
    StatusSetting[] statuses = null;
    String methodName =  "GetAllStatuses";
    String soapAction = NAMESPACE + "/" + methodName;
    SoapObject request = new SoapObject(NAMESPACE, methodName);
    request.addProperty("installation", installation);

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

    AndroidHttpTransport httpTransport = new AndroidHttpTransport(SERVICE_URL);
    try {
        httpTransport.call(soapAction, soapEnvelope);
        statuses = (StatusSetting[])soapEnvelope.getResponse();

    } catch (Exception e) {
        e.printStackTrace();
    }
    return statuses;
}
+5
source share
3 answers

First try and see if you get an answer.

Object obj = envelope.bodyIn; 

if this objone is not zero, try the following.

SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;

, , - .

kSOAP, StatusSetting how, SOAP- StatusSetting.

+5

, :

SoapObject result = (SoapObject) envelope.bodyIn;
String response = result.getProperty(0).toString();
+1

something like that:

SoapObject response = (SoapObject) envelope.getResponse();
   yourArray=new String[response.getPropertyCount()];

   for(int i=0;i<response.getPropertyCount();i++){    
       Object property = response.getProperty(i);
       if(property instanceof SoapObject){
           SoapObject final_object = (SoapObject) property;
           yourArray[i] = final_object.getProperty("YOUR_PROPERTY_NAME");
    }
}
0
source

All Articles