I am using Apache java XML-RPC latest version.
The code for sending the array in Server is the following:
LinkedList<String> messages = new LinkedList<String>();
public String[] getMessages() {
System.out.println("Sent messages");
return messages.toArray(new String[messages.size()]);
}
To receive in the client I have tried something like this:
String[] result = (String[]) client.execute("Message.getMessages", new Object[] {});
This should cast the Object that I receive to the right type (String[]). Unfortunately it doesn't and I get the following error: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
So I am wondering if anyone knows how to properly send and receive arrays in java XML-RPC?
Based on http://ws.apache.org/xmlrpc/types.html the client API will always return Object[]
even if the server returns String[]
I would suggest looping over the result and calling toString()
on each member. ugly, but working.