Friday, September 4, 2009

GroovyWS or Java WS Client?

We had a project this winter/spring which I designed to use Webservices on a web connected to EJBs, the clients we build in Grails for fast development.

Well we started using GroovyWS because that gave us the opportunity to get up and running pretty quick.

First we had some problems with the time it took to generate the stubs everytime we called a web service, however, this was becaus we stupidly put the creation of the client stubs in the actions so it was done every time. This was easy to sol by making a Groovy singleton class and let it create the service stubs once.

Eventually I decided to move over to making JAX-WS clients in Java using Netbeans. The reasons for this was mostly to try to get better performance and the possibility to put on SSL on the Web Service layer. From information I found and the experience during the first month of the project, I realised some shortcommings with GroovyWS mainly:
  • there is no support for https calls using GroovyWS
  • for some reason I had to wrap lists into a class. GroovyWS only regarded the list as one object and took the first one and skipped the rest and making workarounds in the WS-layer to fix this is something I don't want
  • restarting Glassfish sometimes made problems with the grailsapps and made them crash, this I think is because some of the services tokk some time to start and when GroovyWS tried to make stubs they were not there and after that the wars refused to work.
However making a WSClient in Java from Netbeans is an easy task, even if Java 1.6_07 or later is required for JAX-WS it is not such a big deal to make an jar-file and put it into the grailsapps lib folder, after that it is easy to call the java-classes from the Groovy code.

2 comments:

  1. I don't know about the other points but regarding the following point :
    "there is no support for https calls using GroovyWS", I DO NOT agree with that, see : http://groovy.codehaus.org/Using+WS-Security

    ReplyDelete
  2. I agree very much with you. I think that Grails lacks builtin support for webservices in a Groovy way. The ws-client plugin and the GroovyWS is just too hard to make work to be useful. There is hardly any documentation, besides ones showing the most easy situations (calling that damn temperature converter ;-)). In a real-case scenario we operate on complex objects, and there should be proper failure handling.
    Of course you can call any webservice with GroovyWS, but we lack the support of building a complex object. I've tried JAX-WS, and I'm very satisfied with that. It is VERY easy to use, and then you have the support for building up complex objects for the wire.
    I sincerely hope that ws support will improve in Grails/Groovy, as I really do enjoy coding Grails and Groovy :-)

    ReplyDelete