Friday, September 7, 2007

Apache CXF, alternative to Axis?

Working on a small project with a startup and another consultant turned me onto Apache CXF (Celtix XFire). Both of us began looking at open source, specifically Axis 2 to provide a capable Web Service layer for an existing J2EE hosted application. After about a couple of weeks we gave up due to the poor documentation and issues that we ran into. We then decided to look into alternative containers such as Glassfish, JBoss etc and came upon Apache CXF. Some of the factors we decided on were a JAX-WS implementation with the ability to plugin into various implementations and support for the basic WS-* standards such as WS-Security.

Today I used the Apache CXF wsdl2java features to simply generate a client stub to a .Net service. In addition I needed to enable SSL communcation. From install to executing the client, it took 3-4 hours with a bit of debugging on the CXF client configuration file.

Current impressions are good documentation, clean generated code with no major issues.

Check it out at http://incubator.apache.org/cxf

4 comments:

Unknown said...

Here is my email sent to the Architect of Axis2, which I would like to share with others ....

I have read 2 of your articles published on Java.net. Since you are one of the principal architects on the Axis2 project, I would like to express some of my frustrated experiences with your Axis2 API. I have tested both versions of 1.2 and 1.3.

1) Using WSDL2Java to generate the client side code is such a painful experience as it gives tons of mysterious exceptions which are hard to debug if I have some non Hello-World WSDLs. It does not seem that I could even generate the client side Java code against a real life WSDL like those from Amazon or eBay, or even much less complex in my cases. If I am lucky enough to generate the client side code without errors, the code from the ADB binding method is basically unusable as it generates thousands of line of code in one single stub class (16837 to be exact in my case). If I use the XML Beans binding method, I got another side of the problems, too many classes generated (265 of them), plus lots of XSB files (560 of them). The long time needed to generate all these files is not as I have expected. This is not yet to mention about the runtime performance on the client side.

2) Incorporating the Java code first Web services into my existing Java EE application is also not painless with Axis2 if I do not have the luxury to take the AAR approach. Again, my cases are not the same as those Hello-World over simplified services listed in your Axis2 API samples as the business objects exposed for services have many 1:1 and 1:M associations with others non-primitive or non-String data type objects. If I am lucky enough to be able to generate the WSDL on the server side, I would still be unable to generate the client side code out of this WSDL since your Axis2 API could not even understand that WSDL generated by itself.

I really like to use your Axis2 API in my application but most likely I would have to turn to Apache CXF which is much less painful to implement, both the server side and client side. Using the JAXB binding with Spring by default in CXF is significantly simpler on the server side as compared with your Axis2 Spring implementation. Also, I got total of 37 classes generated on the client side using CXF as compared with 825 classes if using Axis2 (What a contrast!).

RonĂ¡n said...

I've managed to do the same. I've created a .net ws using Windows Communication Foundation. CXF generates a working client when I use basic http binding. However I can't seem to get it to work when I use the wsHttpBinding. Have you managed this and do you know what steps are needed to set up ws-security from the CXF client?
Thanks
Ronan

Chris Riley said...

I haven't done any work with Apache CXF WS-Security alas only SSL support. A co-worker has and had to resort to using the Apache CXF message boards to get completion. In his case however he was working on the Server Side interceptors mainly. I would suggest posting questions to the CXF team for assistance.

Unknown said...

I see there was an above post on using CXF to generate stub code and connect to a secure (x509) service.

I am trying to do the same thing now with a Weblogic service - I have the gen'd key... have added it to my keystore.

I am not trying to find a good example of using CXF to use the key to call the service (I am not using HTTPS!!!, only using certs for authenication, not encryption).

The samples that come with CXF only go into using HTTPS for encryption... ugh, not what I need.

Any examples, links, or pointers would be appreciated.

Thanks
AJ