0

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)
tim_yates
  • 167,322
  • 27
  • 342
  • 338
Erki M.
  • 5,022
  • 1
  • 48
  • 74

2 Answers2

2

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.

dmahapatro
  • 49,365
  • 7
  • 88
  • 117
1

You are trying to cast an scalar to array, the prefix [L means that the object is an array of java.lang.Object

Ernesto Campohermoso
  • 7,213
  • 1
  • 40
  • 51