views:

614

answers:

3

Hi,

I am fairly new to the Java world and pretty overwhelmed by the beauty of choice between dozens of libraries doing more or less the same thing, or not.

So with Jetty and CXF. I am looking for a web services stack that has built-in support for a wide range of transports and protocols.

I was under the impression that CXF is the more recent project and would be the preferred choice for new software projects. Especially when it comes to applications that have to talk a variety of different protocols and standards like WS-*.

Can you give your opinion on how those frameworks differ from each other?

Which one has broader support for different protocols and standards?

Which one would you prefer regarding its design e.g. how well they hide transport, authentication, authorization, serialization aspects from application logic?

Any kind of answer very welcome!

Cheers, Alex

+9  A: 

Jetty is a web server and servlet container. CXF is a library for web services. If you want to serve out content like is done with a web server, choose Jetty. If you need to connect to or provide web services, choose CXF. I'm not sure there's any blurred area between the two.

Carl
Great that's exactly the kind of clarification I was looking for!Let's say I have a container framework like OSGi and want to expose a web service. Would it be correct to say that I would host a CXF-based component as an OSGi bundle?As I understand now: Jetty = embeddeable web server, CXF = web services framework that has support for transport like HTTP built in. So it doesn't depend on a host like Jetty?
Alex
Yes, you can host a CXF component as an OSGi bundle. If you are only connecting to an http end point, you don't need Jetty or the OSGi HttpService as CXF can connect using any of the various http client libraries out there. Though if you want to receive connections over HTTP, CXF appears to use Jetty as shown by this doc entry[1]. If you also have the OSGi HttpService deployed, you'll need to make sure it and your CXF Jetty instance are on different ports.[1] http://cwiki.apache.org/CXF20DOC/standalone-http-transport.html
Carl
Brilliant answers, guys! Thay gets me going in the right direction I think.
Alex
A: 

Jetty is a server(a servlet container), so is Tomcat and few others. Jetty is decent, Tomcat has been around for a while and has more documentation and tutorials.

CXF looks like an interesting choice. I've only use directly implementations and CXF was fairly new, I think it's the continuation of XFire project.

CXF looks like a wise choice. When in doubt, I would say go with standards and frameworks built upon them. I would say go through the documentation and for complicated matters, you might want to subscribe to some mailing lists.

anonymous
CXF (CeltiXfire) is a merge of Celtix (IONA) and Xfire (Codehaus).
Pascal Thivent
+4  A: 

There is a misunderstanding here, Jetty and CXF are like apples and oranges, it doesn't make sense to compare them. One is a light servlet engine, the other one is a web services stack.

If you're looking for a web services stack (which is my understanding), consider JAX-WS RI or CXF if you are looking for a JAX-WS compliant stack (both support contract-first or java-first), or SpringWS ("only" contract-first), or maybe Axis2 (I don't like it personally it because of its development and deployment model and its performances).

If you don't need fancy WS-* stuff, I'd suggest to use JAX-WS RI which is included in Java 6 and is compliant with the WS-I Basic Profile 1.1 (so it covers a decent bunch of WS-* standards). If you need more advanced things (like WS-SecureConversation, WS-SecurityPolicy, WS-ReliableMessaging, WS-Trust, WS-AtomicTransactions/Coordination, WS-MetadataExchange, SOAP over TCP which are provided by WSIT/Tango), consider using Metro (Metro = JAX-WS RI + WSIT/Tango).

(EDIT: Answering a comment from the OP about WS-SecureConversation support.

Actually, I think that the stack that supports the most WS-* standards is Metro. You might want to check Apache Axis2, CXF and Sun JAX-WS RI in comparison for more details. But, it is very unlikely that you'll need all of them and things might have slightly changed since the article has been published. So CXF might indeed be an alternative. For example, regarding WS-SecureConversation, CXF does support it too according to its documentation but only with "wsdl-first" projects. Without more details about what you're going to do, it's hard to give you a more accurate answer about which one is the best for you.)

Pascal Thivent
Very interesting! "WS-SecureConversation", yes I need it. As I understand CXF would support it?
Alex
I've updated my answer to cover this part too.
Pascal Thivent
Brilliant answers, guys! Thay gets me going in the right direction I think.
Alex
That comparison link is pretty old. CXF now supports WS-SecurityPolicy, WS-SecureConversation, and much of WS-Trust. We also have experimental support for the soap/tcp thing in Metro on the CXF trunk.
Daniel Kulp
As I wrote, things might have changed since the article has been published :)
Pascal Thivent