1

there seems to be many ways to access a REST web service. but different documentation out there states they all have problems and now i am confused what to use. Here are our options:

HTTPClient - from apache, but deprecated. However Apache does provide some alternative

HttpURLConnection - has bugs in it.

AndroidHttpClient - includes the workaround for a major bug in HttpURLConnection

I really don’t know which one to use from the list above. Is there one which I am missing that I should be using to access a REST web service ?

user3134565
  • 965
  • 1
  • 7
  • 14
  • They all pretty much do the same thing. I use HTTPClient because Apache is the bees knees. – ug_ Feb 16 '14 at 17:09
  • BUT httpclient has been deprecated. .. why would you still use it ? and what do u mean by bees knees? – user3134565 Feb 16 '14 at 17:13
  • Take a look at what these people have to say. http://stackoverflow.com/questions/4799151/apache-http-client-or-urlconnection pretty much sums it up. If you ever have a choice to go Apache code or another library, take a good look into Apache before you choose. Apache code its usually excellently well written. As for the bees knees http://www.urbandictionary.com/define.php?term=Bees%20Knees – ug_ Feb 16 '14 at 17:18
  • 1
    @ns47731: Note that the question and accepted answer that you cite are over three years old. – CommonsWare Feb 16 '14 at 17:20

1 Answers1

2

Ideally, to access a REST Web service, you use a higher-level library, like Retrofit, that handles more of the work for you.

Otherwise, Google's official recommendation is to use HttpURLConnection.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • do you see any problems with AndroidHttpClient ? – user3134565 Feb 16 '14 at 17:23
  • 1
    @user3134565: It is not Google's official recommendation, as `AndroidHttpClient` is merely a slightly configured `HttpClient` implementation, and Google does not recommend `HttpClient` anymore. – CommonsWare Feb 16 '14 at 17:27
  • im not sure that HTTPurlconnection is the answer, please read this: AndroidHttpClient automatically includes the workaround for a major bug in HttpURLConnection in earlier versions of Android as discussed in the Android Developers blog post above. source: https://turbomanage.wordpress.com/2012/06/ – user3134565 Feb 16 '14 at 17:28
  • 1
    @user3134565: Please read [Google's statement](http://android-developers.blogspot.com/2011/09/androids-http-clients.html): "For Gingerbread and better, HttpURLConnection is the best choice. New applications should use HttpURLConnection; it is where we will be spending our energy going forward." – CommonsWare Feb 16 '14 at 17:30
  • @user3134565: Also, we are referring to two different implementations of a class named `AndroidHttpClient`. I though you were referring to one from the Android SDK. The blogger you cited created a *different* class *also* named `AndroidHttpClient`. I have never used that blogger's implementation and so cannot comment on it. – CommonsWare Feb 16 '14 at 17:32
  • ops didn't read carefully – user3134565 Feb 16 '14 at 17:37
  • @user3134565: I nearly missed it myself. Ideally, the blogger would have a chosen a more distinctive name, particularly since the frameworks' own `AndroidHttpClient` should have existed at the time he was writing his library. – CommonsWare Feb 16 '14 at 17:38