java - Sending data via ksoap2 -


i making external database via ksoap2! web service working fine , inserting values in database, through android it's not sending values. cant figure out mistake! can please me? have button , 3 edittext sending (rollno name dues) database

here's code :

package com.example.externaldatabaseksoap2; import java.io.ioexception;  import org.ksoap2.soapenvelope; import org.ksoap2.serialization.propertyinfo; import org.ksoap2.serialization.soapobject; import org.ksoap2.serialization.soapserializationenvelope; import org.ksoap2.transport.httptransportse; import org.xmlpull.v1.xmlpullparserexception;  import android.r.string; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.toast;   public class mainactivity extends activity {     button enter;     edittext rollno,name,dues;       @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);           final string namespace = "http://tempuri.org";          final string method_name = "insert";          final string soap_action = "http://tempuri.org/insert";          final string url = "http://192.168.1.6:5000/service.asmx";          rollno=(edittext)findviewbyid(r.id.etrollno);         name=(edittext)findviewbyid(r.id.etname);         dues=(edittext)findviewbyid(r.id.etdues);         enter=(button)findviewbyid(r.id.enter);         enter.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view arg0) {                 // todo auto-generated method stub                     thread networkthread = new thread(){                      @override                     public void run() {                         // todo auto-generated method stub                         string r=rollno.gettext().tostring();                         string n=name.gettext().tostring();                         string d=dues.gettext().tostring();                          try{                             soapobject request = new soapobject(namespace,method_name);                             propertyinfo pi = new propertyinfo();                             pi.setname("rollno");                             pi.setvalue(r);                             pi.settype(int.class);                             request.addproperty(pi);                              propertyinfo pi1 = new propertyinfo();                             pi1.setname("name");                             pi1.setvalue(n);                             pi1.settype(string.class);                             request.addproperty(pi1);                              propertyinfo pi2 = new propertyinfo();                             pi2.setname("dues");                             pi2.setvalue(d);                             pi2.settype(string.class);                             request.addproperty(pi2);                              soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11);                             envelope.dotnet = true;                             envelope.setoutputsoapobject(request);                              httptransportse ht = new httptransportse(url);                             ht.call(soap_action, envelope);                              //runonuithread (new runnable(){                                 //public void run(){                                     //toast.maketext(mainactivity.this,"inserted", toast.length_short).show();                                 }                             //});                         //}                         catch (exception e){                             e.printstacktrace();                             //toast.maketext(mainactivity.this,e.getmessage().tostring(), toast.length_short).show();                         }                     }                     };                         networkthread.start();             }         });     }       @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }  } 

i think should use asynctask instead of thread such as:

private class exampletask extends asynctask<url, integer, long> {      @override     protected void onpreexecute() {         super.onpreexecute();            }      protected long doinbackground(url... urls) {          return 0;            }      protected void onpostexecute(long result) {         super.onpostexecute(result);      }  } 

the meaning of asynctask<url, integer, long> asynctask<params, progress, result>. can adapt code.

for more information take these websites: http://karanbalkar.com/2014/03/tutorial-78-using-ksoap2-in-android/ , http://developer.android.com/reference/android/os/asynctask.html


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -