Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is an old question (2008) so there are many more options now than there were then:</p> <ul> <li><strong>Apache CXF</strong> has three different <a href="http://cxf.apache.org/docs/jax-rs-client-api.html" rel="noreferrer">REST Client options</a></li> <li><strong><a href="https://jersey.java.net/" rel="noreferrer">Jersey</a></strong> (mentioned above).</li> <li><strong>Spring</strong> also has its own called <a href="http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/" rel="noreferrer">RestTemplate</a></li> <li><strong><a href="http://hc.apache.org/httpclient-3.x/" rel="noreferrer">Commons HTTP Client</a></strong> build your own for older Java projects.</li> </ul> <p><strong><strike>UPDATE</strike> circa 2014:</strong></p> <ul> <li><strike><strong><a href="https://github.com/sonatype/async-http-client" rel="noreferrer">Async-http-client</a></strong> by Sonatype</strike>. <a href="https://github.com/AsyncHttpClient/async-http-client" rel="noreferrer">Ning Async-http-client</a>.</li> </ul> <p>The new kid on the block which provides NIO support (although truthfully I don't think this really improves performance for clients like it does servers).</p> <ul> <li><strong><a href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fluent.html" rel="noreferrer">Apache HTTP Components (4.2) Fluent adapter</a></strong> - Better than old Commons HTTP Client 3 and easier to use for building your own REST client. You'll have to use something like <a href="http://jackson.codehaus.org/" rel="noreferrer">Jackson for JSON parsing</a> support and you can use <a href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d5e49" rel="noreferrer">HTTP components URIBuilder to construct resource URIs</a> similar to Jersey/JAX-RS Rest client. HTTP components also supports NIO but I doubt you will get better performance than BIO given the short request nature of REST.</li> </ul> <p><strong>UPDATE 2016</strong>:</p> <ul> <li><strong><a href="https://github.com/square/okhttp" rel="noreferrer">OkHttp</a></strong> - Supports newer HTTP protocols (SPDY and HTTP2). Works on Android. Unfortunately it does not offer a true reactor-loop based async option (see Ning and HTTP components above). However if you use the newer HTTP2 protocol this is less of a problem (assuming connection count is problem).</li> <li><strong><a href="http://square.github.io/retrofit/" rel="noreferrer">Retrofit</a></strong> - Will auto create clients based on interface stubs similar to some Jersey and CXF extensions. Uses OkHttp.</li> <li>Apache HttpComponents 5 will supposedly have HTTP2 support</li> </ul> <p>A caveat on picking HTTP/REST clients. Make sure to check what your framework stack is using for an HTTP client, how it does threading, and ideally use the same client if it offers one. That is if your using something like Vert.x or Play you may want to try to use its backing client to participate in whatever bus or reactor loop the framework provides... otherwise be prepared for possibly interesting threading issues.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload