java - ECONNREFUSED (Connection refused) android connect to webservice -


i getting connection refused error when trying connect webservice using soapui. when tried using 127.0.0.1 in url, error econnrefused when tried 10.0.2.2, error connection timed out. please can help. thanks. here code on main activity.

private static final string soap_action = "http://tempuri.org/getsmsoutgoing";     private static final string insert_incoming_sms = "savesmsincoming";     private static final string get_outgoing_sms = "getsmsoutgoing";     private static final string namespace = "http://tempuri.org/";     private static final string url = "http://127.0.0.1:62499/wssmsandroid.asmx?wsdl";  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      thread thread = new thread(new runnable() {     @override     public void run() {         try {             getoutgoingsms();         } catch (exception e) {             log.d("not connected: ioexception", "not connected");             e.printstacktrace();         }      } });  thread.start();  }  public string getoutgoingsms() {         string outgoingsms = null;          soapobject request = new soapobject(namespace, get_outgoing_sms);         request.addproperty("sentby", "+639209100000");          soapserializationenvelope envelope = new soapserializationenvelope(                 soapenvelope.ver11);         envelope.dotnet = true;         envelope.setoutputsoapobject(request);          httptransportse ht = new httptransportse(url);         try {             ht.call(soap_action, envelope);              soapobject response2 = (soapobject) envelope.getresponse();             denemelist = new string[response2.getpropertycount()];              (int = 0; < response2.getpropertycount(); i++) {                 denemelist[i] = response2.getproperty(i).tostring();             }             outgoingsms = response2.tostring();          } catch (exception e) {             e.printstacktrace();         }         return outgoingsms;     } 

to access pc localhost android emulator, use 10.0.2.2 instead of 127.0.0.1. localhost or 127.0.0.1 refers emulated device itself, not host emulator running on.

for genymotion use: 10.0.3.2 instead of 10.0.2.2

reference: http://developer.android.com/tools/devices/emulator.html#networkaddresses

ps.: it's been answered in connect failed: econnrefused


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -