I'm using the Android 2.1 API. I download from the web, through ksoap Protocol, the data. The result is this exception org.ksoap2.serialization.SoapPrimitive
and do not understand why.
with debugging, the for
runs correctly the first round, but the second time it hangs education re = (SoapObject) ((SoapObject) envelope.getResponse ()). getProperty (s)
, reporting the error org.ksoap2.serialization.SoapPrimitive
.
Here is the code:
request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("dev", false);
request.addProperty("Cap", input_cap.getText().toString());
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE,Offerta.Offerta_CLASS.getSimpleName(),Offerta.Offerta_CLASS);
androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
int nOff = ((SoapObject) envelope.getResponse()).getPropertyCount();
SoapObject re;
for (int i = 0; i < nOff; i++) {
re = (SoapObject) ((SoapObject) envelope.getResponse()).getProperty(i);
img.setImageBitmap(getBitmap(Integer.parseInt(re.getProperty(0).toString())));
titolo.setText(re.getProperty(1).toString());
descrizioneTitolo.setText(re.getProperty(3).toString());
provincia.setText(getProvincia(Integer.parseInt(re.getProperty(13).toString())));
sintesi.setText(re.getProperty(2).toString());
contenitore_paese.addView(view);
}
The error message sounds like your second property on the following line isn't a SoapObject but a Soap primitive, which is breaking it at runtime because you are type casting it.
re = (SoapObject) ((SoapObject) envelope.getResponse()).getProperty(i);