android


ksoap2 custom serialized response


I'm having problems with casting response to my custom class:
Here is the code which calls request:
SoapObject request = new SoapObject(RequestData.NAMESPACE, METHOD_LOGIN);
request.addProperty(PROPERTY_USERNAME, RequestData.USERNAME);
request.addProperty(PROPERTY_API_KEY, RequestData.API_KEY);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.enc = SoapSerializationEnvelope.ENC;
envelope.xsd = SoapSerializationEnvelope.XSD;
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE(RequestData.URL);
transport.debug = true;
transport.call("", envelope);
LoginResponse response = (LoginResponse)envelope.bodyIn;
And here is serialized response class:
public class LoginResponse implements KvmSerializable {
String sessionId;
public LoginResponse(String sessionId) {
this.sessionId = sessionId;
}
public LoginResponse() {
}
#Override
public Object getProperty(int i) {
return sessionId;
}
#Override
public int getPropertyCount() {
return 1;
}
#Override
public void setProperty(int i, Object o) {
sessionId = o.toString();
}
#Override
public void getPropertyInfo(int i, Hashtable hashtable, PropertyInfo propertyInfo) {
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "loginReturn";
}
}
Error I get says: SoapObject cannot be cast to com.myapp...LoginResponse. It happens at this line:
LoginResponse response = (LoginResponse)envelope.bodyIn;
If I write
SoapObject response = (SoapObject)envelope.getResponse;
instead of previous line, I don't get error, but I want to do it with custom serialized class.
Also, how to handle failed response?
Thanks

Related Links

Android how to receive list object from server?
Realm db ChangeListener persistence - memory leak
Error in Android Toolbar
Looping inside onPostExecute AsyncTask
Android : How to detect onTouch event on a view, with touch down outside the view?
Run game local (file:///) Construct 2
How to call Context.getSystemService(String) from JNI?
Where does onCreate gets in Bundle type argument?
CollapsingToolbarLayout button hide listener
on click notification how to close activity before opening it, if it is running already
In espresso, what is the best way to act on an array of elements that all have the same resource id?
android listview inside cardview onTouch listener conflict / sensitivity
After Upgrading to Google Play Services 9.0.0, App Hangs in DynamiteModulesC
Retrofit2, how to convert response to base class?
Cannot get Estimote Beacon to be seen using altbeacon android
Having trouble Parsin a JSON Array in Android Studio

Categories

HOME
phantom-dsl
localization
apache-jena
pagination
object
datastore
replace
static-site
database-normalization
rom
tail
google-cloud-datalab
augeas
pega
why3
qsqlquery
keytool
atlassian-stash
imessage
systemtime
aggregation
zxing
interbase
custom-post-type
sinch
vex
panoramas
paragraph
left-join
fstream
instantiation
sendbird
dynamic-jasper
apriori
logback-groovy
ssrs-2014
android-exoplayer
monkey-testing
dynamic-linq
jquery-ui-draggable
serde
fclose
colorbar
cup
janus
rsa-archer-grc
cubism.js
pacemaker
jboss-tools
simevents
nss
gcloud-ruby
fink
jbase
concurrentmodification
fiware-monitoring
google-books
ons-api
zscript
dronekit-android
sha512
fail2ban
beatsmusic
angular-gettext
metatrader5
spy++
verold
live555
ios8-extension
square-bracket
model-driven-development
ebay-lms
cnf
chart-director
android-loadermanager
panda3d
sentestingkit
os.system
listitem
procedures
ikimagebrowserview
denied
webdev.webserver
tournament
rmdir
nhprof
metaweblog
office-2007
aspmenu
zend-rest
cldc
scrubyt
linfu-dynamicproxy
java1.4

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App