开发者

Problems consuming web service from groovy script

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 en开发者_如何学运维lighten me please?

Thank you very much


There seems to be a bug in GroovyWS, documented here on their JIRA.

It's currently Unresolved and was added in 2010.

I'm personally getting the same error with anything other than the trivial example service, with Groovy 1.8.0, GroovyWS 0.5.2

Hopefully somebody can find the issue and fix it - WSClient could definitely be a great alternative to traditional CXF/JAXB


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜