The Server

You can develop your web service using a groovy script and/or a groovy class. Imagine, we want to publish a web service performing simple arithmetics. First, we have to write the business class implementing the basic operations. In our example, we chose to just implement simple add and square operations. Note that this class is quite generic and could be use locally.

class MathService {
  double add(double arg0, double arg1) {
    return (arg0 + arg1)
  double square(double arg0) {
    return (arg0 * arg0)

Then we have to publish this service. In order to do so, we use WSServer and create one so called node linking our class with a URL.


def server = new WSServer()

server.setNode("MathService", "http://localhost:6980/MathService")


That's all !