Android app crashes when consuming web-service -


this question has answer here:

i trying consume web service through android. use ksoap2 library , follow this example. whenever enter data text field, app crashes. following error:

process: com.tinyvoice.webservice, pid: 14447 java.lang.verifyerror: org/ksoap2/soapenvelope         @ com.tinyvoice.webservice.webserviceactivity$1.onclick(webserviceactivity.java:49) 

here app link:

public class webserviceactivity extends appcompatactivity { /**  * called when activity first created.  */ private static string soap_action1 = "http://tempuri.org/fahrenheittocelsius"; private static string soap_action2 = "http://tempuri.org/celsiustofahrenheit"; private static string namespace = "http://tempuri.org/"; private static string method_name1 = "fahrenheittocelsius"; private static string method_name2 = "celsiustofahrenheit"; private static string url = "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl";  button btnfar, btncel, btnclear; edittext txtfar, txtcel;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_web_service);      btnfar = (button) findviewbyid(r.id.btnfar);     btncel = (button) findviewbyid(r.id.btncel);     btnclear = (button) findviewbyid(r.id.btnclear);     txtfar = (edittext) findviewbyid(r.id.txtfar);     txtcel = (edittext) findviewbyid(r.id.txtcel);      btnfar.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             //initialize soap request + add parameters             soapobject request = new soapobject(namespace, method_name1);              //use add parameters             request.addproperty("fahrenheit", txtfar.gettext().tostring());              //declare version of soap request             soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11);              envelope.setoutputsoapobject(request);             envelope.dotnet = true;              try {                 httptransportse androidhttptransport = new httptransportse(url);                  //this actual part call webservice                 androidhttptransport.call(soap_action1, envelope);                  // soapresult envelope body.                 soapobject result = (soapobject) envelope.bodyin;                  if (result != null) {                     //get first property , change label text                     txtcel.settext(result.getproperty(0).tostring());                 } else {                     toast.maketext(getapplicationcontext(), "no response", toast.length_long).show();                 }             } catch (exception e) {                 e.printstacktrace();             }         }     });      btncel.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             //same logic farenheit  ... } } 

i using android studio , added ksoap2.jar libs folder , added library. thanks

if you're using android studio have add

 compile 'com.google.code.ksoap2-android:ksoap2-android:3.1.0' 

in dependencies in gradle , add

repositories {     maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } } 

in buildtypes in gradle

as faced same issue in past , got solved using above trick.

also network related task in background using asynctask


Comments