views:

34

answers:

1

Hello,

I'm having some problems trying to consume a web service from a groovy script. I'm using WSClient lib.

If I execute the example posted at groovy's website:

@Grab(group='org.codehaus.groovy.modules', module='groovyws', version='0.5.2')
import groovyx.net.ws.WSClient

proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader)
proxy.initialize()
result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"

Works fine, but once I try to consume another service it crashes with this error:

INFO: Created classes: javac: no source files Usage: javac use -help for a list of possible options 07-jul-2010 9:55:57 org.apache.cxf.endpoint.dynamic.DynamicClientFactory createC lient GRAVE: Could not compile java files for http://xxx:8080/x/services/xxx?wsdl. Caught: groovyx.net.ws.exceptions.InvokeException: java.lang.NullPointerExceptio n at groovy-ws.run(groovy-ws.groovy:13)

The code it's exactly the same (apart from wsdl url which correponds to one internal server). The main difference I found between them is that the second wsdl is RPC style while the first one isn't. I've read that there's some problems to consume RPC like webservices from groovy with WSClient lib. ¿Does anyone know how to consume RPC like webservices with WSClient? ¿Could anyone enlighten me please?

Thank you very much

A: 

Don't use WSClient is the best answer I can give you. For anything but simple services I've found WSClient does not work well. Instead use what ever java based web service client your most comfortable with and call it from Groovy.

Jared