Java REST implementation: Jersey vs CXF [closed]
Solution 1:
I have used both, but for different purposes. CXF worked great to parse a WSDL and create Java POJOs to interact with, so CXF is pretty good for client-side WSDL services. I'm currently using Jersey for server-side implementation and I am impressed with the simplicity of getting up-and-running with RESTful services using Jersey.
As Jersey is mainly devoted to RESTful services and CXF deals mostly (all?) with SOAP, I think it comes down to whether you want to work with SOAP or REST, and determine the best framework for the job from there. Personally, I am more in the REST camp than SOAP, but my needs are different. Should I be in a situation where the vendor/customer/company I write the service for needs some sort of contract, I might still push for REST (and REST's equivalent for contract-based services, WADL), but would likely be required to implement a SOAP service, in which case I would look at CXF first and everything else second.
Personally, Jersey is pretty good for a JAX-RS framework, although don't exclude RESTEasy, by JBoss. I like both, but the documentation for RESTEasy is better.
For CXF, the documentation is OK, but I ran into inconsistencies in how I needed to handle SSL and HTTP Proxies, but it worked itself out eventually. CXF does provide more out of the box regarding these additional features, and I would say RESTEasy would provide the equivalent functionality for RESTful frameworks.
Solution 2:
I have only used Jersey (with great satisfaction) so I cannot give a real comparison. Things you might want to consider:
- CXF is packaged up with SOAP stack support so you bring in a lot of SOAP-related weight you'll never use when you build a RESTful system. (There are plans to split the packaging as far as I know, though)
- Jersey comes with a number of non-standard additions to JAX-RS that are very helpful. There is also a client side core framework which is designed quite nicely.
- [Warning: Shameless plug ahead (sorry)]: I have been working on an extended Jersey client side framework that encourages proper use of REST on the client side and is (IMHO at least) very natural to use. It is planned to announce it this (or next) week - if you care about the client side a lot, give it a try. Personally, I'd consider that a huge pro-Jersey argument.
HTH,
Jan
Solution 3:
Did you consider RESTlet? It is a powerful package to quickly build RESTful web services. The people behind RESTlet also write the RESTlet In Action book which is currently in early access. The chapters that are already available do a very good job of explaining REST and detailing how you go about designing a REST api.
Solution 4:
If you are concerned about the details of converting a solution developed with Jersey to run on CXF, Glen Mazza posted a collection of Jersey samples ported to Apache CXF on GitHub. The README files have notes for each sample regarding necessary changes made.
Solution 5:
I've used Apache CXF for JAX-WS and Jersey for JAX-RS so I can't comment about CXF and REST. It was easy to set up a REST example using Jersey. The documentation was adequate. I haven't used RESTEasy but Jersey looks to have more traction and more recent updates.
A good book for implementation guidelines is RESTful Web Services Cookbook.