Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 38 Next »

Module Overview

GroovyWS is taking over GroovySOAP as CXF replaces XFire. The major difference here is that GroovyWS is using Java5 so if you need to stick to 1.4 please continue to use GroovySOAP.

Warning: Most of the documentation is adapted from the former GroovySOAP documentation and will improve in the future. I tried to make it as accurate as possible but feel free to report any error.

Warning: GroovyWS is Java5 dependent (due to CXF) and has been tested using groovy-1.5.

Warning: In order to use GroovyWS, you must ensure that GroovySOAP is not in your classpath (~/.groovy/lib) 

Download

Distributions

GroovyWS is available in two packages:

  • as a full jar containing all CXF JARs and dependencies. It is located here
  • as a jar containing all except the jetty server and servlet files. It aimed at being deployed into third party containers. It is located here

    Installing

You just need to place the above mentioned JAR file in your ${user.home}/.groovy/lib directory.

Pre-requisites

As the pre-requisites are quite tricky to handle, an all-in-one JAR file is distributed  

Documentation

The javadoc is here

Getting Started

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

  1. Publishing a web service
  2. Consuming a web service

Complex types

The Server

Let say we have a server that manage a library in which you can add a book, find a book and get all the books. The server code will probably look like this (wink)

  1. BookService.groovy

  2. with the class Book being something like that.
    Book.groovy

    To ignore the metaClass property a custom type mapping must be defined (for details refer to Aegis Binding).
    Book.aegis.xml

    However, if you compile custom data types from Java the bytecode won't contain a metaClass property and, hence, there is no need to define a custom mapping.

The Client

The good think here is that the client does not have to know about the Book class. It is automatically generated during the proxy creation time and can be used by your client. Here it is located in the defaultnamespace package since no package was used on the server side.

Here is how the client looks like now:

Iterating over the books is slightly more complicated since SOAP wrap the arrays in an element (in our case ArrayOfBook). Therefore you have to extract a field from that element. In our case:

More Information

Using proxies

If you are using a proxy for accessing internet, you can use the following environment variables to get rid of it:

  • proxyHost
  • proxyPort
  • proxy.user
  • proxy.password

or directly use the following in your code:

Using basic authentication

If your server use basic authentication, you need to set up the following properties:

  • http.user
  • http.password

or directly use

Setting a time out value

If your want to set a time out value for the connection to the server just use:

Using SOAP 1.2 (in test/review)

If your server is proposing SOAP 1.2 endpoints, then you can use:

TODO

 If you have ideas how the API should look, do not hesitate to post on the user list ;-

Known problems (and work around)

Demos with public web services

Currency rate calculator

There exist a lot of web-services available for testing. One which is pretty easy to evaluate is the currency rate calculator from webservicex.net.
Here is a small swing sample that demonstrate the use of the service. Enjoy !

TerraServer-USA by Microsoft


TerraServer supports a Tiling Web Service that enables you to build applications that integrate with USGS imagery found on their site. Here is a sample of what you can achieve.

will give:

Developers

Guillaume Alleon

Source Control

http://svn.codehaus.org/gmod/groovyws

Building

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

in the directory conting the source tree.

Contributing

Community

Mailing List(s)

use user@groovy.codehaus.org

Issue tracker

There is a GroovyWS http://groovy.codehaus.org/GroovyWS category in JIRA

Articles

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

  • No labels