Metro Plugin for Grails Framework

Metro plugin allows applications developed with Grails framework to expose service classes as SOAP Web Services. It uses the SOAP implementation from Metro web service stack, which includes JAX-WS.

How to Install

Download the plugin (links below), and in your grails application directory, invoke:
grails install-plugin grails-metro-1.0.2.zip

How to Use

  1. In grails application directory, invoke:
    grails create-service Calculator
    which creates class grails-app/services/CalculatorService.groovy

  • Implement your methods, e.g. add, multiply, and annotate the class with @WebService, @WebMethod annotations. The resulting class should look like below:
    import javax.jws.*
    
    @WebService(targetNamespace="http://com.calculator")
    class CalculatorService {
    
        @WebMethod
        def int add(int i, int j) {
            return i+j;
        }
        
        @WebMethod
        def multiply(int i, int j) {
            return i*j;
        }
    }
  • Run your application, using
    grails run-app
  • Test if your service is deployed, by pointing your browser to:
    http://localhost:8080/CalculatorApp/services/CalculatorService
  • Note that the targetNamespace attribute is required only for classes in default package. If your classes are specified in a package, the targetNamespace value is defaulted based on package name and doesn't need to be specified explicitly.

    How it works

    The plugin uses Jax-ws spring integration. When the grails application is executed, classes are scanned for @WebService annotations. If such annotation is present, appropriate entries are generated to grails-app/conf/spring/resources.xml, and wsgen is called to generate required classes.

    Another option is to specify web service classes in web-app/WEB-INF/sun-jaxws.xml file. If the file exists, only entries in the file are used to generate entries in resources.xml or web.xml. No other classes are scanned for presence of @WebService annotations.

    Download

    Version Changes
    1.0.2DownloadIncluded patch from Alex Peters - fixes issue with web services in packages.
    1.0.1DownloadFixed problem with services dependency. Updated for Grails 1.0.3.
    1.0Download

    Sources

    Sources are stored in Subversion. Read more
    Terms of Use; Privacy Policy; Copyright ©2013-2014 (revision 20131025.e7cbc9d)
     
     
    Close
    loading
    Please Confirm
    Close