| Deprecated Module Before using GroovySOAP, make sure to check GroovyWS |
SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. Groovy has a SOAP implementation based on
Xfire which allows you to create a SOAP server and/or make calls to remote SOAP servers using Groovy.
You just need to download this jar file in your ${user.home}/.groovy/lib directory. This jar file embeds all the dependencies.
You can develop your web service using a groovy script and/or a groovy class. The following two groovy files are valid for building a web-service.
This example shows how to use custom data types with Groovy SOAP. The code can be downloaded from here.
The PersonService.groovy script contains the service implementation and the custom data type (Person).
Server.groovy is equivalent to the previous example.
For each class compiled by the groovy compiler a metaClass property is added to the bytecode. This property must be excluded from being mapped by XFire, otherwise an error will be reported when trying to obtain the WSDL document from http://localhost:6980/PersonServiceInterface?wsdl. The reason is that XFire cannot map groovy.lang.MetaClass. To ignore the metaClass property a custom type mapping must be defined (for details refer to Aegis Binding).
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 (ImageClient.groovy)
The (ugly) server part embedding the image which is Base64 encoded (ImageServer.groovy):
and the missing and secred part is here.
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 !
And here is the result: 