casting a soap object to a own object

老子叫甜甜 提交于 2019-12-12 01:51:56

问题


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 KvmSerializableinterface 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!