What steps will reproduce the problem?
1. I wrote WCF servcice, very simple method returning Complex object, SimpleDTO
attached below
2. I created similar class in Android - Implementing KvmSerializable
3. When i call the method and receive result i get castException.
What is the expected output? What do you see instead?
Cast retrieved object to my object on android.
What version of the product are you using? On what operating system?
- Win8, Android, KSOAP 3.0.0
Please provide any additional information below.
My code on server-side:
1) called method:
[OperationContract]
SimpleDTO SayHello3();
2) class:
[DataContract(Namespace = "{MyNamespace}")]
public class SimpleDTO
{
[DataMember]
public String Field1 { get; set; }
[DataMember]
public String Field2 { get; set; }
}
On the android side i have
1) Dto class:
public class SimpleDTO implements KvmSerializable {
public SimpleDTO() {
}
public String Field1;
public String Field2;
@Override
public Object getProperty(int arg0) {
switch (arg0) {
case 0:
return Field1;
case 1:
return Field2;
}
return null;
}
@Override
public int getPropertyCount() {
return 2;
}
@Override
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
switch (index) {
case 0:
info.type = PropertyInfo.STRING_CLASS;
info.name = "Field1";
break;
case 1:
info.type = PropertyInfo.STRING_CLASS;
info.name = "Field2";
break;
default:
break;
}
}
@Override
public void setProperty(int index, Object value) {
switch (index) {
case 0:
Field1 = value.toString();
break;
case 1:
Field2 = value.toString();
break;
default:
break;
}
}
}
2) and call the service like that:
webService.addMapping("SimpleDTO", new SimpleDTO().getClass());
webService.call();
SimpleDTO s = (SimpleDTO) webService.envelope.bodyIn;
webService is a object of my class which wraps the code.
I call the method like that:
request = new SoapObject(this.nameSpace, this.methodName);
...
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
...
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(this.url,
this.connectionTimeout);
androidHttpTransport.debug = true;
registerMarshals();
androidHttpTransport.call(this.soapAction, envelope);
...
I register marshals but only for UUID, double, date.
When i dump request and response i get the messagess attached for this issue.
Exception is java.lang.ClassCastException: "org.ksoap2.serialization.SoapObject
cannot be cast to ....models.SimpleDTO"
Is there any solution to cast/retrieve all object - not primitive property by
property?
Original issue reported on code.google.com by jarek.sz...@gmail.com on 14 May 2013 at 4:08
Original issue reported on code.google.com by
jarek.sz...@gmail.com
on 14 May 2013 at 4:08Attachments: