Phoenix
Phoenix

Reputation: 8923

Apache commons httpclient or Resttemplate of spring?

I am trying to figure out between commons http client and resttemplate which one is a better choice, if I need to create an HttpClient which sends a request xml and gets back a response xml. The xml contains metadata information which the server side will store in the database. Also, what about the plain old java class of java.net.HttpURLConnection ?

Upvotes: 0

Views: 2833

Answers (1)

Vincent Devillers
Vincent Devillers

Reputation: 1628

You should definitly use the RestTemplate which can use java classes of java.net package, commons-httpclient or http-component via the interface ClientHttpRequestFactory.

ClientHttpRequestFactory has some implementations by default:

  • SimpleClientHttpRequestFactory -> for the plain old java class of java.net.HttpURLConnection

  • HttpComponentsClientHttpRequestFactory -> for Apache HttpComponents HttpClient

  • CommonsClientHttpRequestFactory (@Deprecated) -> for Jakarta Commons HttpClient

Upvotes: 1

Related Questions