Grails + CXF Example
Ok, we've been trying to get full fledged web services (providing) working in Grails for quite a while, it felt like it should be easy, as all the bits were there, but all of the plugins to date were more proof of concept vs Enterprise ready (e.g. no control over namespaces).
So, the target was to get CXF running with the following key requirements:
- WSDL First
- Minimal change required to CXF generated interface classes
- Bound to Grails services so we can re-use business logic and interact with domain classes
Step 1: Grails App + CXF
Create a simple Grails application (working from the ground up is the best way to explain it, rather than trying to explain our existing application), create a simple domain class, controller and service.
Download Apache CXF (I used 2.1): http://cxf.apache.org/ and extract somewhere on your PC.
Copy the following libraries from the CXF Installation over into your Grails application lib folder:
Next, add a resources.xml file to your grails-app/conf/Spring folder:
Next, install templates for your app (grails install-templates), then go into src/templates/war and edit web.xml, add the following:
Next, ensure that you turn off the inbuilt URL Mapping for the /ws/* in conf/UrlMapping.groovy: