i calling web service android client application. after getting response when trying display getting classcastexception. following code:
public void onclick(view v) { setcontentview(r.layout.report); soapobject request = new soapobject(namespace, method_name); epcdetails epcdetails=new epcdetails(); epcdetails.setepcid(input_val.gettext().tostring()); request.addproperty("id", id soapserializationenvelope sse=new soapserializationenvelope(soapenvelope.ver11); sse.setoutputsoapobject(request); sse.addmapping(namespace, productdetailsrequest.productdetailsrequest.getsimplename(), productdetailsrequest.productdetailsrequest); sse.implicittypes=true; sse.setaddadornments(false); androidhttptransport aht=new androidhttptransport(url); try { aht.call(soap_action, sse); soapobject response= (soapobject) sse.getresponse(); item_code.settext((charsequence)(response.getproperty(6))); desc.settext((charsequence) (response.getproperty(5))); price.settext(calc_price.tostring()); } catch (ioexception e) { e.printstacktrace(); } catch (xmlpullparserexception e) { e.printstacktrace(); }
i getting exception @ item_code.settext((charsequence)(response.getproperty(6)));
12-20 19:26:12.864: error/androidruntime(811): fatal exception: main 12-20 19:26:12.864: error/androidruntime(811): java.lang.classcastexception: org.ksoap2.serialization.soapprimitive 12-20 19:26:12.864: error/androidruntime(811): @ com.truevue.modules.report.mainsimulation.onclick(mainsimulation.java:123) 12-20 19:26:12.864: error/androidruntime(811): @ android.view.view.performclick(view.java:2408) 12-20 19:26:12.864: error/androidruntime(811): @ android.view.view$performclick.run(view.java:8816) 12-20 19:26:12.864: error/androidruntime(811): @ android.os.handler.handlecallback(handler.java:587) 12-20 19:26:12.864: error/androidruntime(811): @ android.os.handler.dispatchmessage(handler.java:92) 12-20 19:26:12.864: error/androidruntime(811): @ android.os.looper.loop(looper.java:123) 12-20 19:26:12.864: error/androidruntime(811): @ android.app.activitythread.main(activitythread.java:4627) 12-20 19:26:12.864: error/androidruntime(811): @ java.lang.reflect.method.invokenative(native method) 12-20 19:26:12.864: error/androidruntime(811): @ java.lang.reflect.method.invoke(method.java:521) 12-20 19:26:12.864: error/androidruntime(811): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 12-20 19:26:12.864: error/androidruntime(811): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 12-20 19:26:12.864: error/androidruntime(811): @ dalvik.system.nativestart.main(native method)
please suggest soln asap.
regards, rahul
because type of webservice return string ,so can solve way:
object response= sse.getresponse();
when webservice return values type byte[] ,you can it
soapobject response=(soapobject)envelope.bodyin;
Comments
Post a Comment