tags:

views:

792

answers:

3

Hi, Could any one please suggest a better open source Java API for invoking REST services? Also wanted to know if Restlet API supports NTLM authentication.

Thanks

+2  A: 

It's REST - the whole point is you don't need an API per se, just HttpURLConnection. You should be able to interact with any truly RESTful service with the basic Java SDK alone. You can get fancier with Apache Commons HTTPClient - but it's not a necessity.

Gandalf
It's not a necessity, but neither is an IDE, the point is that there are libraries to deal with the hard parts (HTTPS, representation processing etc) so you can focus on delivering functionality
Rich Seller
A: 

I am using resteasy as the rest frameworks and it works just fine and easy (both to rewrite and to test, same as easymock). As a sample code:

@Path("/webservice")

public class Web {

@GET
@Path("{web}")
@ProduceMime("application/xml")
public String test(@QueryParam("param") String param, @PathParam("web") String web)

{ // code here } }

  • @Path is your "root path" of the class (your real "root" would be configured on components.xml)
  • @GET is from Rest
  • ProduceMime or ConsumeMime is the mime you should consume or produce
  • @QueryParam is the params of the url and @PathParam the parameters you should get

So this get will receive a call from /webservice/web?param=lalala and return a string in the application/xml format

Diego Dias
+2  A: 

Check out Restlet. It has a good client API.

Example usage:

Request request = new Request(Method.GET, "http://my/rest/api");

Client client = new Client(Protocol.HTTP);

Response response = client.handle(request);

//get response representation and process
Rich Seller
I agree. Also, the new version of Restlet which is under development, and nearing release, 2.0, also supports a new approach to "calling" resources — client-side resources. In other words, you can instantiate a resource object with the URL of the remote resource, and then get a representation of it, send a new representation, etc. I haven't used it yet, but I'm intrigued by it.
Avi Flax