I am working with a groovy script in SoapUI and I need to make a XMLRPC call to a server. I am using groovy.net.xmlrpc.XMLRPCServerProxy
for this and invokeMethod needs a parameter as an object. The example that I am trying to use need an integer as parameter and now I've been casting this integer like a madman, but always keep getting:
Caught: java.lang.ClassCastException: java.lang.Integer cannot be cast to [Ljava.lang.Object; java.lang.ClassCastException: java.lang.Integer cannot be cast to [Ljava.lang.Object; at xmlrpctest.run(xmlrpctest.groovy:17)
import groovy.net.xmlrpc.XMLRPCServerProxy
def base_url = 'http://www.cookcomputing.com/xmlrpcsamples/RPC2.ashx'
def serverProxy = new XMLRPCServerProxy(base_url)
def num = 1;
def response = serverProxy.invokeMethod('examples.getStateName', (Object)num)
Try:
def response = serverProxy.invokeMethod('examples.getStateName', [num])
Have a look at the API. It expects the args
to be a List
or an Object[]
.
Remember when you use def num = 1
the type is always the wrapper object (java.lang.Integer
) of the primitive.