问题
Can I cast a SoapObject to a predefined java object?. I use ksoap2
I am trying to do it inside an AsncTask class and this is my code segment.
I have created a class called Citizen
.
SoapObject result = (SoapObject)envelope.getResponse();
citizen = (Citizen)result;
the error I get is cannot cast SoapObject to Citizen
I have my AsynType Declaration like this.
private class AsyncTaskRunner extends AsyncTask<String, String, Citizen>
How do I solve this?
回答1:
No experience with this but when I read the javadoc of SoapObject it looks like your Citizen class must implement the KvmSerializable
interface so you can:
KvmSerializable result = (KvmSerializable)envelope.getResponse();
citizen = (Citizen)result;
or why not directly:
citizen = (Citizen) envelope.getResponse();
来源:https://stackoverflow.com/questions/25052913/casting-a-soap-object-to-a-own-object