質問

I have a webservice that returns a complex object(say RouteDetails).when i am calling this webservice from my android code in which i have used ksoap library i am getting a response in soapobject but when i try to cast it to my complex object it throws classcast exception while when i print it on log it show me output like this -

" RuoteDetails{name="abc",id="2"} "

where RouteDetails is my object Now i am completely unaware of how to retrieve my object . Can any one please help. i hav gone through various links but couldnt find a proper solution.

役に立ちましたか?

解決

Ksoap2 can parse response into several types of objects.

  1. SoapObject - the default one. You can use its methods getProperty, getPropertySafely, getPropertyAsString and so on for getting data. i.e String value = response.getPropertySafelyAsString("propertyName", "default");
  2. Class which implements KvmSerializable interface and registered by addMaping().
  3. Class which implements Marshal interface and registered by addMaping().

In the last two cases you will get your object from envelope.getResponse() (in the first case your will get SoapObject). So you can get your data from SoapObject or implement KvmSerializable or Marshal interfaces and register your class.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top