android ksoap2 Caused by: java.lang.RuntimeException: Cannot seralize (double data type)

by mindus » Thu, 30 Sep 2010 14:18:46 GMT


Sponsored Links
 Hi
In my project i am using ksoap2-android-assembly-2.4-jar-with-
dependencies.jar for web service purpose.

I got able to access the service and passing simple parameters and get
the objects and iterate it.

But the problem is i cant able to send the complex object. Can anybody
know how to pass the complex object with date and double values.

Employee object have string name, int number, double salary and Date
dateOfBirth.

And the employee object implements KvmSerializable
name="Mike"
number=2;
salary=20000
dateOfBirth = new Date();

and the code is

SOAP_ACTION = "http://xysed/GetHRA";
METHOD_NAME = "GetHRA";

TextView authenticate = new TextView(this);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

PropertyInfo pi = new PropertyInfo();
pi.setName("employee");
Employee e = new Employee();
e.setNumber(4);
e.setName("Ananth");
e.setSalary(20000);
e.setDob(new Date());
pi.setValue(e);
pi.setType(Employee.EMPLOYEE_CLASS);
request.addProperty(pi);
request.addProperty("employee", e);


SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
Marshal dateMarshal = new MarshalDate();
dateMarshal.register(envelope);
//envelope.addMapping(Employee.NAMESPACE, "Employee", new
Employee().getClass());
try {
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);

//String fullName = (String)envelope.getResponse();
Log.v("Full String :", envelope.getResponse().toString());
Log.v("body in :", envelope.bodyIn.toString());
Log.v("body out :", envelope.bodyOut.toString());

authenticate.setText(envelope.getResponse().toStri ng());
this.setContentView(authenticate);

} catch (IOException ioe) {
ioe.printStackTrace();
} catch (XmlPullParserException xpe) {
xpe.printStackTrace();
}



I pass this employee object as a request i got an error like

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.oak.soap.test/com.oak.soap.test.WebserviceDisplay}:
java.lang.RuntimeException: Cannot serialize: 20000.0

here 20000.0 is a salary ( double value)

ERROR/AndroidRuntime(287): Caused by: java.lang.RuntimeException:
Cannot serialize: 20000.0


Can anybody provide samples for how to pass complex object as request
to web service

Thanks
mindus

--