I’ve started using SOAP in Groovy. As I’m new both to SOAP and to Groovy , this is a little basic.
Note: all of the following is checked for Windows 7, jdk 1.6.0_21. , groovyws 0.5.2, eclipse 3.6 (Helios), groovy 1.7.5
**What is SOAP? **
You can find the w3c tutorial here , but you don’t need me for that.
Basically , it solves the problem of”How the hell should I know what your web service expects me to send him?!”
It’s done in the following way: when someone publishes a SOAP web service , you publish a url that looks like”http://…..wsdl” . (like this: http://soapclient.com/xml/soapresponder.wsdl). This url is actually an xml document , that has pre-defiend nodes , that tell you what are the names of the function , what they expect to get , and what they return.
The cool thing is that most SOAP libraries know to do everything by themselves : You just give them the wsdl address , and they already create all the objects for you , and absolve you from the annoyance of parsing the xml and building objects you really couldn’t care less about.
More hands on:
First of all , a very simple & basic soap service to use when you’re writing your SOAP version”Hello, World” : http://soapclient.com/xml/soapresponder.wsdl (Don’t see anything? You’re probably using Chrome , aren’t you? Chrome has an issue with XML)
It has one method , called Method1(String a, String b) and return the 2 strings.
So far , everything looks nice. But for a lot of people trying to run this , it won’t work. Why?
Because of countless dependency issues.
- You need to get the groovyws-0.5.2.jar (or later) for the WSClient. (It won’t compile otherwise)
- Now it compiles , but it throws nasty errors your way , ahh? You’re probably getting this error :
It’s because what you have is only an API , and you need countless other dependencies.
- Hopefully , you’re working on a maven project (aren’t you? see next comment) . Add this dependency:
- Build your project a new . maven will take care off all the dependencies for you.
- Still doesn’t work? you get this nasty error? add this dependency to the pom:
Now you can finally run!
**Don’t use a maven project? **
You have 2 options:
- Somewhere in the WWW there is a groovyws-standalone-0.5.2.jar , which includes all the
dependencies. I , unfortunately , couldn’t find it anywhere.
- Make a pom.xml as mentioned above , with the dependencies , and build it . All the
dependencies will be in your repository , and you can use them from there.