java - Consuming Simple WCF from Android -


i writing simple app, needs verify login details through mysql database. cannot use php, opted wcf service model. now, have wcf working through browser. of methods working in browser , returns desired json output, order, post service interface;

    [operationcontract]     [webinvoke(method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrapped, uritemplate = "getuserauthenticated/{value1}/{value2}")]     bool getuserauthenticated(string value1, string value2);      [operationcontract]     [webinvoke(method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrapped, uritemplate = "getisusermodel/{value}")]     bool getisusermodel(string value);      [operationcontract]     [webinvoke(method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrapped, uritemplate = "getisuseractive/{value}")]     bool getisuseractive(string value); 

as stated, works. when trying consume service app so;

    public void userauthenticated(string email, string password) {         try {             url url = new url("http://10.0.0.180:15021/service1.svc/getuserauthenticated/" + email + "/" + password);             httpurlconnection httpurlconnection = (httpurlconnection) url.openconnection();             httpurlconnection.setrequestmethod("get");              log.d("response code: ", "" + httpurlconnection.getresponsecode());             inputstream in = new bufferedinputstream(httpurlconnection.getinputstream());             string response = org.apache.commons.io.ioutils.tostring(in, "utf-8");             log.d("response string: ", response);          } catch (malformedurlexception mue) {             mue.printstacktrace();         } catch (ioexception ioe) {             ioe.printstacktrace();         }     } 

i getting java.io.filenotfoundexception.

02-08 04:44:53.015 7425-7457/com.testapp w/system.err: java.io.filenotfoundexception: http://10.0.0.180:15021/service1.svc/getuserauthenticated/user/pass 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ com.android.okhttp.internal.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:186) 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ com.testapp.loginclass.userauthenticated(loginclass.java:29) 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ com.test.welcomescreen$loginauthenticator.doinbackground(welcomescreen.java:103) 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ com.testapp.welcomescreen$loginauthenticator.doinbackground(welcomescreen.java:90) 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ android.os.asynctask$2.call(asynctask.java:288) 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ java.util.concurrent.futuretask.run(futuretask.java:237) 02-08 04:44:53.015 7425-7457/com.testapp w/system.err:     @ android.os.asynctask$serialexecutor$1.run(asynctask.java:231) 02-08 04:44:53.019 7425-7457/com.testapp w/system.err:     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) 02-08 04:44:53.019 7425-7457/com.testapp w/system.err:     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) 02-08 04:44:53.019 7425-7457/com.testapp w/system.err:     @ java.lang.thread.run(thread.java:841) 02-08 04:44:53.023 7425-7425/com.testapp w/egl_genymotion: eglsurfaceattrib not implemented 02-08 04:44:53.155 577-912/system_process w/inputmethodmanagerservice: window focused, ignoring focus gain of: com.android.internal.view.iinputmethodclient$stub$proxy@529adc88 attribute=null, token = android.os.binderproxy@52b37f04 

could please point me in right direction here? examples i've been able find use deprecated httpclient handle wcf consumption, , don't think it's practice use drepecated classes handle this.

i kinda lost here, appriciated!

edit: googled bit , made httpurlconnection print response code getting. getting 400 bad request service.

edit2:

i created azure site run service through, which, time being has solved problem. however, still interested in why cannot connect service when running on local host.

so solved it. did was;

  1. i opened port attempting connect on in windows firewall. in case 8008. opened both outgoing , ingoing traffic.
  2. i installed iis express, , set local page on ip workstation has.
  3. after lot of rumaging on interwebz, , here on stack overflow, found other had problems connecting local iis addresses through genymotion, using standard ip localhost, 10.0.3.2. thread here on found guide;

https://developer.chrome.com/devtools/docs/remote-debugging

turns out, had port forward device. , working. can connect wcf service through genymotion emulator on workstations ip @ port 8008.

i hope helps someone.

cheers.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -