开发者

Consuming WCF Restful Service on Android

I am trying to comsume a self-hosted WCF service which simply returns a String in JSON format. It takes a very long time around 2-3 minutes to get the response on Android Device, where as on any other computer it works fine. Could anyone help me on this? Thanks in Advance.

Below is my code to access the service.

 try{

 HttpClient httpclient = new DefaultHttpClient();
 HttpGet request = new HttpGet("http://192.168.1.83:8000/GetOffers");
 ResponseHandler<String> handler = new BasicResponseHandler开发者_如何学编程();
 //you result will be String :
 result = httpclient.execute(request, handler);


   } catch (ClientProtocolException e) {
   // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (IOException e) {
    // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (JSONException e) {
    // TODO Auto-generated catch block
   e.printStackTrace();
 }


Are you sure your phone's connection is fast enough? Also I think you are testing locally so getting stuff on the computer would be very fast. Fetching things from the actual server would be slow. I use the same code and works for me pretty well when I'm on a wi-fi connection.


Ironically, I was suspecting Windows Defender for slower response and I was right. Once I disabled it and restarted the server, everything seems to be working fine. I don't know what was causing Windows Defender to slow down WCF service response. Anyways, I am up and running now. Abhinav...You were right, there was no problem at client side. Thanks anyways.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜