Consume WCF Service on Android
-
Everyone: I have a WCF service that returns it's results in JSON format. It works fine when I put the url in a browser. I'm have a small test Anroid application in which the user clicks a button, the service is called and the value returned is displayed. The program always hangs on the HttpResponse ... execute statement. I'm using the Android studio for development and as far as I can tell, no error message returns. I also made sure to include the 'permission.INTERNET' statement in the manifest. Here's the code:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://XXXXXXXX/jsonwebservice/Service1.svc/getCNSP/CN-000186");HttpResponse response = httpClient.execute(httpget);
HttpEntity responseEntity = response.getEntity();Thanks for the help, Dale
-
Everyone: I have a WCF service that returns it's results in JSON format. It works fine when I put the url in a browser. I'm have a small test Anroid application in which the user clicks a button, the service is called and the value returned is displayed. The program always hangs on the HttpResponse ... execute statement. I'm using the Android studio for development and as far as I can tell, no error message returns. I also made sure to include the 'permission.INTERNET' statement in the manifest. Here's the code:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://XXXXXXXX/jsonwebservice/Service1.svc/getCNSP/CN-000186");HttpResponse response = httpClient.execute(httpget);
HttpEntity responseEntity = response.getEntity();Thanks for the help, Dale
-
Everyone: I have a WCF service that returns it's results in JSON format. It works fine when I put the url in a browser. I'm have a small test Anroid application in which the user clicks a button, the service is called and the value returned is displayed. The program always hangs on the HttpResponse ... execute statement. I'm using the Android studio for development and as far as I can tell, no error message returns. I also made sure to include the 'permission.INTERNET' statement in the manifest. Here's the code:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://XXXXXXXX/jsonwebservice/Service1.svc/getCNSP/CN-000186");HttpResponse response = httpClient.execute(httpget);
HttpEntity responseEntity = response.getEntity();Thanks for the help, Dale
Most probably you are making the network call on the main thread. This isn't allowed (NetworkOnMainThreadException).