java.io.filenotfound android exception on web service call -


i getting exception java.io.filenotfound android exception on web service call in android.but when run same url in browser works fine.i communication project running on local host in visual studio. url this:

http://10.0.2.2:7378/highriseesite/appservices.svc/savewc?wcid=3646&wodetailid=480982&psid=2084&wcdate=07/14/2015 &wcompleted=1&remarks=&rabill=0&connectivityid=0&length=0&breadth=0&height=0&execby=0 

when use same url in browser replacing 10.0.2.2 localhost works fine webservice gets called.but when same url called android studio project exception:

java.io.filenotfound 

and in visual studio project running , webservice being called exception as:

object reference not set instance of object. 

but same url works fine in browser.i not able detect wrong this.any kind of appreciated.

my code accessing webservice this:

 for( wcompletiondata itm:lstwc)                 {                       if(float.parsefloat (itm.getcompqty())>0.0)                      {                           ur = "http://" + serverdetails.hostserver + "/appservices.svc/savewc?wcid=" + itm.getwo_no().trim() + "&wodetailid=" + itm.getwodetail_id().trim() + "&psid=" + itm.getps_id().trim() + "&wcdate=" + currentdatetimestring.trim().trim() + " &wcompleted=" + itm.getcompqty().trim() + "&remarks=&rabill=" + itm.getrabill_id().trim() + "&connectivityid=0&length=0&breadth=0&height=0&execby=0";                          //string ur = "http://"+serverdetails.hostserver+"/appservices.svc/taskquanitylist?materialid="+matrid+"&projectno="+proid+"&taskno="+taskid;                            log.d("urlgggrn", ur);                            // replace own wcf service path                          url json = new url(ur);                          urlconnection jc = json.openconnection();                          bufferedreader reader = new bufferedreader(new inputstreamreader(jc.getinputstream()));                            line = reader.readline().tostring();                             log.d("line", line);                          wcno = wcno + line + ",";                         } 

i using same code on activity , works fine on activity.

to rid of file not found exception while requesting url android should avoid white space url. if need pass parameter data contain space have use below code

string param1 = "happy coding"; string url = "http://example.com/query?q=" + urlencoder.encode(param1 , "utf-8"); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -