views:

538

answers:

2

I'm going through the first examples from the new Java Web Services: Up and Running book. I tried to go through the SOAP client example for Java on page 13, but in Groovy.

So here is my Groovy shell code:

import javax.xml.namespace.QName
import javax.xml.ws.Service
import java.net.URL

url = new URL("http://someURL?wsdl")
qname = new QName("http://someURL", "SomeURLImplService")
service = Service.create(url, qname)

But this fails with this error:

ERROR groovy.lang.MissingMethodException: No signature of method: \
static javax.xml.ws.Service.create() is applicable for argument types: \
(java.net.URL, javax.xml.namespace.QName) values: {http://someURL?wsdl, \
{http://someURL}SomeURLImplService}

I do not understand this, since Groovy tells me this method with that signature does indeed exist:

groovy:000> Service.class.getMethods().each {println it}
public static javax.xml.ws.Service \
javax.xml.ws.Service.create(java.net.URL,javax.xml.namespace.QName)
...

Does anybody know what I am doing wrong here?

+2  A: 

I tried to run your code with no modifications and it worked fine for me. Your issue might be related to the Java version or the classpath. The javax.xml.ws (JAX-WS) is only part of the Java SE starting with Java 6. If you are not running this test in Java 6, that might be your problem. That is probably not your issue since if you were not, I would not expect you to be able to resolve those interfaces.

The other thing it might be is a classpath issue. External JAX-WS providers can be plugged into the Java runtime. Do you have anything on your classpath that is the JAX-WS provider? Perhaps it is an earlier version.

Chris Dail
It also works fine for me.
chanwit
+1  A: 

I tried again by downloading Groovy manually (instead of using the distribution that came with Ubuntu). Now it works. Go figure.

lindelof