tags:

views:

45

answers:

2

Newbie question:

I'm new to groovy & soap , so I might be missing out on something here:

I'm trying to communicate with a very basic web service :

import groovy.net.soap.SoapClient
... 
def proxy = new SoapClient("http://soapclient.com/xml/soapresponder.wsdl")
res = proxy.Method1("ABC", "123");
println (res);

It seems the connection works , but when I try to invoke "Method1(..)" , I keep getting

Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.InvokerHelper.getInstance()Lorg/codehaus/groovy/runtime/Invoker;
    at groovy.net.soap.SoapClient.invokeMethod(Unknown Source)

This is the relevant part of the WSDL:

<message name="Method1">
<part name="bstrParam1" type="xsd:string"/>
<part name="bstrParam2" type="xsd:string"/>
</message>
−
<message name="Method1Response">
<part name="bstrReturn" type="xsd:string"/>
</message>
−
<portType name="SoapResponderPortType">
−
<operation name="Method1" parameterOrder="bstrparam1 bstrparam2 return">
<input message="tns:Method1"/>
<output message="tns:Method1Response"/>
</operation>
</portType>

What am I doing wrong?

+2  A: 

The help page for Groovy Soap says it has been deprecated (on Mar 03, 2008), so probably hasn't had any love for quite a while :-/

It recommends to use GroovyWS, and that page says that this should work:

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

try {
  proxy = new WSClient( "http://soapclient.com/xml/soapresponder.wsdl", this.class.classLoader)
  proxy.initialize()

  result = proxy.Method1("ABC", "123")
  println res
}
catch( e ) {
  e.printStackTrace()
}

However, when you run this, you get:

[snip]
Caused by: org.xml.sax.SAXParseException: Unexpected <schema> appears at line 0 column 0
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.unexpectedX(NGCCRuntimeEx.java:488)
    ... 54 more

I can't see why this WSDL is wrong however... I'll keep looking

tim_yates