Apache CXF and Glassfish Metro for consuming web services

For a project I need to call some web services for which there is a WSDL schema. I have briefly looked at some contenders and only took consuming of web services into account and not the producing of web services,

I decided to go the JAX-WS route, since this appears to become a standard: JSR 224. Java 6 will have it as a feature.

The JAX-WS choice does mean that Axis2 cannot be used. I don’t really mind since I’ve experienced some real pain there in previous projects. I’m not the only one. Hani sums it up nicely.

JAX-WS contenders

A bit of googling looked like the contenders are:

  • JBossWS
  • CXF
  • Metro

Because it seemed I was the first one using the here unnamed web services, I first decided to play with Amazon web services, because documentation and examples for Amazon web services are widely available.
This excellent article explains how to use AWS ECS with Metro and with CXF. I did not go for the ANT route and used wsdl2java and wsimport.sh. to generate the Java code.

JBossWS

JBossWS seems a bit tied to JBoss 5 and because I need to work with JBoss 4.0.5, I ignored that option.

Since I will consume a webservice, I feel that JBossWS could still be viable. However the pain I had converting the CXF Geronimo stuff to JBoss stuff (more on that later), confirmed my suspicion that JBossWS would not be an easy route in my environment. This is not to say that when using JBoss 5, you cannot have total bliss with JBossWS.

CXF

CXF is still an Apache incubator project. It is a merge of XFire and Celtix. The wsdl2java script did run without problems. When you want to use the generated code you need the following jars, according to the documentation:

  • cxf.jar
  • commons-logging.jar
  • geronimo-activation.jar (Or the Sun equivalent)
  • geronimo-annotation.jar (Or the Sun equivalent)
  • geronimo-javamail.jar (Or the Sun equivalent)
  • neethi.jar
  • jaxb-api.jarv
  • jaxb-impl.jar
  • stax-api.jar
  • XmlSchema.jar
  • wstx-asl.jar
  • xml-resolver.jar
  • jaxws-api.jar
  • saaj-api.jar
  • saaj-impl.jar

I could call ECS without any problems, however the Geronimo jars were a thorn in my eye, I tried to replace them with a JBoss equivalent. I entered a world of pain. With jboss.org.lang.Annotation problems (update JBossWS) and then javax.annotation.PostConstruct problems.
So I concluded that it was not possible to remove the Geronimo jars. Upgrading to the latest JBossWS implementation got me dependent on JBoss 5 it seemed, which is no option.
So if you can live with Geronimo jars and 15 jars in total, give or take a few (removing 1 or 2 seems not to break anything) then you are good to go.

Although I ran into the same observation as Glen Mazza. jaxws:enableWrapperStyle not working in CXF

Metro

I downloaded the standalone version instead of a complete Glassfish distribution.
I had to alter the wsimport.sh script, because WSImport needs JAF. I added the activation.jar from the JBoss distribution to the classpath in the wsimport.sh script. The generated code enabled me to call ECS without any problems.
I needed the following jars:

  • webservices-extra.jar
  • webservices-rt.jar
  • webservcies-api.jar

Compared to CXF, Metro just seems more environment friendly. Of course this could be complete rubbish, since those three jars can be completely bloated with everything but the kitchen sink.

For now I will use Metro and see how this will go.

10 Responses to Apache CXF and Glassfish Metro for consuming web services

  1. Salaboy says:

    Can you explain how to install (step by step) metro in Jboss 5? because i can’t find any good tutorial..

  2. Ronald Pulleman says:

    I haven’t tried JBoss 5. But what is precisely the problem? Just including the jars does not work for you?

  3. Felix says:

    Did you tried with jdk1.6 or jdk1.5. I’have tried with 1.6 and it dosen’t work.
    Thanls a lot,

  4. Ronald Pulleman says:

    1.5

  5. Felix says:

    I’ve tried with JBoss 5 beta2 and Java 1.5 and it works without adding any library!!
    Just put the generated Client classes.

  6. Wim Verreycken says:

    Hi,

    You can run CXF (or anything else for that matter)
    without the geronimo jars (can’t stand them).
    Here’s the way :

    Put the following libs, or newer versions, in
    {JDK_HOME}\jre\lib\endorsed
    (f.e. C:\Program Files\Java\jdk1.6.0_03\jre\lib\endorsed) :
    activation.jar
    dom.jar
    endorsed.txt
    jaxb-api.jar
    jaxb-impl.jar
    jaxb-xjc.jar
    jaxb1-impl.jar
    jaxp-api.jar
    jaxws-api.jar
    jsr173_1.0_api.jar
    sax.jar
    xalan.jar
    xercesImpl.jar

    from your JSP container’s lib dir, for tomcat6 this is f.e.
    C:\Program Files\apache-tomcat-6.0.16\lib
    copy the following 3 files to your classpath :
    commons-el.jar (or el-api.jar)
    jsp-api.jar
    servlet-api.jar

    That should do the trick. Hope it helps.

    fyi, I copied all required libraries from spring 2.5.2 with dependecies distro.
    That gives you a head start if you want to use Spring + you’re sure there compatible.
    (I suppose you can dl them seperately or use maven, but that’s the way I did it).

    Oh yeah, don’t forget… and remove all geronimo jars from the cp!
    (You might wanna do this first, certainly if you’re using some ide:)

    Cheers,

    Wim

  7. Ronald Pulleman says:

    Thanks Wim for the tip.
    I always considered using endorsed as cheating, but it is good if you want to use these jars for all your Java applications.

    But my biggest problem is that I can’t go th JBoss 5. I’m using ATG 2007.1 which is dependent on jboss 4.5

  8. Wim Verreycken says:

    Ronald, can you please explain the exact problem you run into? (with respect to classpath, library version, jdk version; jboss version etc)?What doesn’ work/go in 5 that does in 4.5?

  9. Wim Verreycken says:

    btw I’m sorry for replying this late, but I didn’t get an email notify of your post

  10. Ronald Pulleman says:

    Wim,
    I don’t know. I have not tried the new JBoss! And it has been a while now 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: