Hi, see my comments bellow.
Regards Stano On 1/14/08, AbelMacAdam <[EMAIL PROTECTED]> wrote: > > > Hi, > > How do you know what the correct cast type is for the return of a request? # You have to know the interface. And then you can expect the correct types also returned by xml rpc. If if you don't know, you can use instanceof or reflection. I have the following piece of code: > [code] > XmlRpcClientConfigImpl config = new > XmlRpcClientConfigImpl(); > try { > config.setServerURL(new > URL("https://{aServer}/svcmon/RPC/server.php")); > } > catch (MalformedURLException mue) { > addItem("MalformedURLException " + mue); > System.exit(-1); > } > addItem("XmlRpcClientConfigImpl created"); > > XmlRpcClient client = new XmlRpcClient(); > client.setConfig(config); > Object[] params = new Object[]{}; > try { > String result = > (String)client.execute("organisation.getAllOrganisations", params); > addItem("Read 'result' " + result.getClass().getName()); > > } > catch (ClassCastException cce) { > addItem ("ClassCastException: " + cce); > System.exit(-1); > } > catch (XmlRpcException xre) { > addItem("XmlRpcException: invocation of the remote method > failed"); > addItem("XmlRpcException.getLocalizedMessage returned: " + > xre.getLocalizedMessage()); > System.exit(-2); > } > [/code] > > This code generates the following output: > Creating XmlRpcClientConfigImpl > XmlRpcClientConfigImpl created > ClassCastException: java.lang.ClassCastException: [Ljava.lang.Object; > cannot > be cast to java.lang.String > > What I was expecting (and saw on a comparable request using Phyton command > line) was: > ['customer01', 'customer02', 'customer03, ... , 'customer0N']. > > Anyone know what is wrong in my code? # First of all, I didn't see organisation.getAllOrganisations but from your Python example I expect array as return type. Also you can see in error that return type is Object[] and I guess that items of this arrays are strings. (Don't be confused with String[], it is little bit different) TIA, > Abel > -- > View this message in context: > http://www.nabble.com/XML-RPC-and-casting-the-correct-type-tp14797401p14797401.html > Sent from the Apache Xml-RPC - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >