views:

102

answers:

1
+1  Q: 

ksoap2 not working

Hi

I cant figure out why i cannot get the reponse from a call to a web service using ksoap2.

The call sends an MSISDN value to a web service and should return a string. I can see on the web service that it does get called and the string is returned but am unable to see the returned string on the device.

My code is as followed:

            SoapObject request = new SoapObject("http://fc.mobiledatacapture/", "getParameters");
            request.addProperty("arg0", MSISDN);
            SoapSerializationEnvelope envelope =
                new SoapSerializationEnvelope(SoapSerializationEnvelope.VER10);

            envelope.bodyOut = request;

            HttpTransport ht = new HttpTransport(url);

            //call web service method
            ht.call("\"getParameters\"", envelope);

            SoapObject response = (SoapObject)envelope.getResponse(); //marker

            parameterString = (String) response.getProperty(0);

So i know that the web service gets called but i never get a result for parameterString.

After adding some printouts and error checks, i have found that the code does not get past the line with the comment - "//marker". Right before that line i did a check to see if envelope was null and it wasn't. Yet, this code block catches a null error.

So i presume that means the reponse is null, but how can i then get the value returned by the web service?

+1  A: 

No worries. I changed the code as follows and i got the String my web service returned:

    Object response = envelope.getResponse();
    parameterString = response.toString();
Chris