android - Getting serialization exception while calling SOAP WEB-Service -
i getting serilization error @
androidhttptransport.call(soap_action, envelope);
here's full code webservice class
public class webservicecall extends asynctask<string, void, void> { string result = ""; httptransportse androidhttptransport; public webservicecall() { // todo auto-generated constructor stub } @override protected void doinbackground(string... urls) { try { soap_action = namespace + method_name; // adding values request object request = new soapobject(namespace, method_name); // adding double value request object propertyinfo weightprop = new propertyinfo(); weightprop.setname("weight"); double w = double.parsedouble(urls[0]); weightprop.setvalue(w); weightprop.settype(double.class); request.addproperty(weightprop); // adding string value request object request.addproperty("fromunit", "" + urls[1]); request.addproperty("tounit", "" + urls[2]); envelope = new soapserializationenvelope(soapenvelope.ver11); // can comment line if web service not .net // one. envelope.dotnet = true; envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(url); androidhttptransport.debug = true; try { // soap calling webservice androidhttptransport.call(soap_action, envelope); // got webservice response result = envelope.getresponse().tostring(); } catch (exception e) { // todo: handle exception e.printstacktrace(); } } catch (exception e) { // todo: handle exception e.printstacktrace(); } return null; } @override protected void onpostexecute(void r) { setresult(result); } }
logcat error
> 04-10 10:25:05.612: w/system.err(919): java.lang.runtimeexception: cannot serialize: 20.0 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.serialization.soapserializationenvelope.writeelement(soapserializationenvelope.java:708) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.serialization.soapserializationenvelope.writeproperty(soapserializationenvelope.java:692) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.serialization.soapserializationenvelope.writeobjectbody(soapserializationenvelope.java:661) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.serialization.soapserializationenvelope.writeobjectbody(soapserializationenvelope.java:645) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.serialization.soapserializationenvelope.writeelement(soapserializationenvelope.java:702) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.serialization.soapserializationenvelope.writebody(soapserializationenvelope.java:618) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.soapenvelope.write(soapenvelope.java:198) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.transport.transport.createrequestdata(transport.java:111) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.transport.httptransportse.call(httptransportse.java:119) 04-10 10:25:05.612: w/system.err(919): @ org.ksoap2.transport.httptransportse.call(httptransportse.java:95) 04-10 10:25:05.622: w/system.err(919): @ com.postwebservicing.webservicing$webservicecall.doinbackground(webservicing.java:121)
try this, after u make call add these lines:
soapprimitive response = (soapprimitive) envelope.getresponse(); string resstring=response.tostring();