Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Consume WCF Service on Android

Consume WCF Service on Android

Scheduled Pinned Locked Moved Android
androidhelpcsharpwcfjson
3 Posts 3 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dalewill
    wrote on last edited by
    #1

    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

    T G 2 Replies Last reply
    0
    • D dalewill

      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

      T Offline
      T Offline
      tabrej
      wrote on last edited by
      #2

      Kindly provide the LogCat in case it is showing any warning or errors. Make sure you are running HTTP connection in Async Task.

      1 Reply Last reply
      0
      • D dalewill

        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

        G Offline
        G Offline
        Giannakakis Kostas
        wrote on last edited by
        #3

        Most probably you are making the network call on the main thread. This isn't allowed (NetworkOnMainThreadException).

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups