6

Possible Duplicate:
Rest clients for Java?

If I want to use Java to create a REST client, what should I use?

Can i use CXF?

Community
  • 1
  • 1
jojo
  • 13,583
  • 35
  • 90
  • 123

7 Answers7

7

There is a Jersey client API that allows you to easily implement clients in Java

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
7

I used Restlet. I really liked it and wrote a blog post about my experience.

Vinnie
  • 12,400
  • 15
  • 59
  • 80
  • Oh sorry - I see you said REST "client". My bad. Restlet is used to to create the server-side implementation. I've also used Http Unit to test this service. – Vinnie May 15 '09 at 12:57
  • 3
    Actually, Restlet is a full-blown API and implementation for creating both RESTful Servers **and** clients. I've written many REST clients using Restlet, with excellent results. – Avi Flax May 15 '09 at 15:24
3

I've had success using HttpClient from Jakarta Commons.

Also Java comes with URLConnection but you might want to look at this comparison with HttpClient.

Apache CXF does support REST clients (see here) but seems like overkill (CXF is a general 'services' framework and therefore complicated with support for CORBA, SOAP etc.)

Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
  • HttpClient and URLConnection are both good options, but I'd recommend using them with the Restlet API, which is an abstraction layer one level up from these low-level classes. Restlet lets you write code which is decoupled from any specific client library, and then swap in and out whichever client library you prefer, using its "connector" paradigm. – Avi Flax May 15 '09 at 15:26
  • Apache CXF 2.2.1 also contains a REST client. See: http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-ClientAPI – Daniel Kulp May 16 '09 at 02:08
0

I tried using examples given in this ling http://cxf.apache.org/docs/jax-rs-client-api.html I faced the problem that the Interface or the Impl may not be always avilable to client side to generate proxy. I also tried wadl2java to see if clients are generated. CXF 2.6 version did not create client class.

I am happy with HTTPclient call till some concrete implementation changes ways to write client.

Note: We are using only CXF with Java thus only experimenting with CXF. other implementation may give different results

R-JANA
  • 1,138
  • 2
  • 14
  • 30
0

Use HTTP4e REST client add-on for Eclipse. It is simple to use and has Java/C#/Ruby/Flex/ActionScript/etc.. one click code generation.

  • your links are dead. Is there any other alternatives? I'm looking for mobile usage with put, get, delete, and asynchronous technique. :D – gumuruh Mar 22 '12 at 09:56
0

imo there is hardly a need for a framework, simply use the servlet API and implement the request methods you need aka POST / GET / PUT / DELETE / HEAD

an example: http://www.exampledepot.com/egs/javax.servlet/com_mycompany_MyServlet.html

KingInk
  • 536
  • 1
  • 3
  • 7
0

I think it really depends on the app and your environment, but I find resteasy really easy (since it is so declarative) and configurable. See chapter 30 for the client documentation.

Alexander Torstling
  • 18,552
  • 7
  • 62
  • 74