Apache CXF – Simple WebService With Spring

A reader posted a comment to one of my old blogs on XFire. That rekindled my interest so I checked the XFire web site only to be informed that XFire is now Apache CXF (version 2.2.3 at this moment in time).

So how hard would it be to convert my old example to CXF. Turned out to be a piece of cake. Had to change the following:

  1. Updated the maven dependencies to reflect CXF libraries.
  2. web.xml – to point to the CXF Servlet
  3. Spring context (app-context.xml) – It was now a lot simpler and cleaner.
  4. Finally I used CXF wsdl2java utils to generate a client

Maven pom.xml

The web.xml…

The Spring context file – app-context.xml

The wsdl2java command I executed was:

Run the project using maven: mvn clean package jetty:run

The WSDL is located at the address mentioned above in the wsld2java command.

Finally I ran the test client that wsdl2java generated…class named EchoService_EchoServicePort_Client

The output was:

Click here to download the maven project for this blog.