Sunday, 20 November 2011

Grails + CXF Example - Contract First WSDL

There is an excellent tutorial for doing contract first WSDL with CXF in grails here:
http://docs.codehaus.org/pages/viewpage.action?pageId=85983334

After a bit of mucking about I managed to improve it slightly.

Still couldn't get the cxf simpleBean tag to allow injection of grails services - it works but the resultant service fails with errors like:


[Namespace] [method] was not recognized.  (Does it exist in service WSDL?)</faultstring></soap:Fault></soap:Body></soap:Envelope>"

I think this is because spring / grails is proxying the beans set up in resources.xml so the object passed to simpleServer does not have the annotation necessary to publish the webservice.  Found this:
http://www.techper.net/2009/12/03/cxf-method-not-found-when-further-annotated/

Anyway, the solution is to not use simpleServer and do it yourself in Bootstrap as follows:
1) Inject the grails service that implements the web service into bootstrap
2) start the web service in Bootstrap init:


        System.out.println("Starting Security WebService");
        Object implementor = injectedService
        String address = "/serviceAddress";
        Endpoint.publish(address, implementor);
    }



No comments:

Post a Comment