5

I googled some information about web services, it seems like a enterprise level application. I found that RESTful design is very cool idea on this. I find that Apache CXF looks cool, it support RESTful design and Java. It is a good choice for beginner to start writing an application using Apache CXF? or any other framework is suggested?

6 Answers 6

8

I'd go for Jersey, the RI of JAX-RS (JSR 311), the Java API for RESTful Web Services (i.e. a standard).

4

I recommend to use JAX-RS because IMHO it is the most neutral framework in terms of telling you how REST should be done. I have not used CXF, only Jersey. It is a very solid implementation and comes with a good client side connector, too (client side not part of JAX-RS yet).

Being neutral with regard to 'how to do REST' is important because there is not yet an acknowledged 'best' way to approach certain aspects (e.g. design of hypermedia).

Congrats to going the REST way - you won't regret it.

Jan

2

The much simpler implementation for a beginner would be spring 3.0 REST support. Spring MVC 3.0 has REST support and is very much simpler compared to Apache CXF.

3
  • Wow... better read the question next time... missed the word web service. Thought about a RESTful architecture style.
    – spa
    Feb 13, 2010 at 23:16
  • @spa Can you please elaborate on what you are saying or a resource which explains better about them? Feb 13, 2010 at 23:30
  • I think @spa was answering my comment, this is not a direct comment to your answer. Feb 14, 2010 at 1:19
1

Restlet in another RESTful web framework for Java : http://www.restlet.org/

3
  • It seems not so famous like the Apache CXF and Spring, is there any special features in Restlet?
    – DNB5brims
    Feb 13, 2010 at 16:11
  • You can have a list of the features provided by Restlet : restlet.org/about/features Apache CXF and Spring MVC are very good projects. But, unlike Restlet, they are not focused on REST applications.
    – Desintegr
    Feb 13, 2010 at 16:19
  • Restlet came before JAX-RS so it has it's own architecture. I did see the feature that they added JAX-RS 1.0 integration.
    – TJR
    Nov 16, 2010 at 18:55
1

I get started REST with RESTEasy and get it up in 30 minutes. You can use it as stand-alone lib in your favorite servlet container without all this JBoss stuff.

1

You should try PlayFramework. Just take a loot at a sample route file and you will know how easy it is to use play to implement RESTFul web app:

# ====== Order service =========================
GET /orders Orders.list
GET /orders/{<[0-9]+>id} Orders.show
PUT /orders/{<[0-9]+>id} Order.saveUpdate
POST /orders Orders.saveNew
# ==============================================

And corresponding controller methods:

public class Orders extends Controller {
   public static void list() {
      List<Order> orders = Order.all();
      render(orders);
   }
   public static void show(long id) {
      Order order = Order.findById(id);
      notFoundIfNull(order);
      render(order);
   }
   public static void saveUpdate(long id, Order update) {
      Order order = Order.findById(id);
      notFoundIfNull(order);
      order.update(update);
      show(id);
   }
   public static void saveNew(Order order) {
      order.save();
      show(order.getId());
   }
}

There are some utilities enable you to interact with other Web Services:

String url = "https://ajax.googleapis.com/ajax/services/search/web";
Map<String, Object> params = new HashMap<String, Object>();
params.put("v", "1.0");
params.put("q", searchStr);
params.put("key", Play.configuration.get("app.google.key"));
params.put("userip", myIpAddr);
HttpResponse resp = WS.url(url).params(params).get();
return resp.getString();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.