GroovyWS

Module Overview

If you need to quickly consume and/or publish WS-I compliant web services, GroovyWS can help you.

Installation

If you are online and using the latest groovy version, here is the no-brainer way to use GroovyWS:

import groovyx.net.ws.WSClient

@Grab(group='org.codehaus.groovy.modules', module='groovyws', version='0.5.1')
def getProxy(wsdl, classLoader) {
  new WSClient(wsdl, classLoader)
}
proxy = getProxy("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader)
proxy.initialize()

result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"

Make sure to have the correct GroovyWS grape config file
Make sure that you have javac in your path - this is required for automatic generation of the classes on the client side
Groovy 1.6.3 relies on Ivy 2.0 which has problem computing some dependencies checksums - if you experience this problem, you have to either download a Groovy snapshot or upgrade Ivy to version 2.1.0 (or above) in your $GROOVY_HOME directory.

If you need more control, see the GroovyWS installation notes.

Getting Started

GroovyWS comes with two sets of APIS that are briefly described below using a simple example.

When your service is using groovy beans on the server side, you may want to control the fields that are serialized. This is done using a small xml file located next to your script. A small example is demonstrating this:

When consuming a web service, you may also be using some complex types. Those types are automatically generated from the WSDL, compiled and made available via your classloader. The client API is providing you a method to easily instantiate such a complex object from its name. Obviously, knowing the class name can be difficult when using a complex web service and may require to study the contract (WSDL). In order to help the user, GroovyWS is logging the names of the classes generated on the fly.

The client side integrates seamlessly with Grails applications.

You can also used secured web-services with GroovyWS. If you wish to do so check Using WS-Security.

There exists a lot of public web services. We provide two examples that show how easy it is to use GroovyWS to tap on these resources.

More WSClient configuration is available if you need to use proxies, basic authentication and security related features.

The javadoc is probably the ultimate place to the missing bits. If you are missing a feature email us user@groovy.codehaus.org.

Articles

  1. A nice article from Geertjan's blog with several examples: http://blogs.sun.com/geertjan/entry/groovy_web_service
  2. An article explaining the difference between the different WSDL styles http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

They use GroovyWS

If you use GroovyWS, please let'us now and feel free too add a quote in this section.

Community

  • The build process is using gradle.  In order to build the sources from svn, just run:
     ./gradlew
    

    in the directory containing the source tree.

  • Feel free to contribute by testing, giving your feedback, reporting bugs and sending patches.

Labels

groovyws groovyws Delete
tools tools Delete
supporting supporting Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jun 24, 2008

    Danilo Araya says:

    Hello World... When i set up a client to the following WSDL http://siagfqa.pap...

    Hello World...

    When i set up a client to the following WSDL

    http://siagfqa.paperless.cl:8083/axis2/services/ExtincionReconocimiento?wsdl

    using

    def extincion = new WSClient("http://siagfqa.paperless.cl:8083/axis2/services/ExtincionReconocimiento?wsdl", this.class.classLoader)

    i'm getting the following error

    Caused by: org.xml.sax.SAXParseException: A class/interface with the same name "
    cl.paperless.siagf.ws.Exception" is already in use. Use a class customization to
     resolve this conflict.

     Does anybody knows how to fix it?

  2. Feb 16, 2009

    olivier FRESSE says:

    I've updated the sources link My biggest issue with this module is to set the c...

    I've updated the sources link

    My biggest issue with this module is to set the client timeout...

    The web services I use takes a long time to perform a background operation. And no way to set the timeout value.

    (known issue : http://jira.codehaus.org/browse/GMOD-50?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel )

    I'm afraid I'll have to take a look in the code ...