I am attempting to access an XML-RPC API method using a Java client. I'm fairly certain that the server is written in Python.

The API is part of the wiki farm Wikidot.com

API info: http://www.wikidot.com/doc:api
API method info: http://www.wikidot.com/doc:api-methods

Does anyone here know what the equivalent of this statement is in Java?

>>> s.user.sites({'user': 'username'})

From what I can tell, the parameter being passed into the method is a hashmap where 'user' maps to 'username', etc. However regardless of what Java data type I pass in to the method - Map, String array, Object array, ... - I keep getting an exception thrown indicating that the "Calling parameters do not match signature"

I originally tried this (Object[] array storing 2 separate Strings), and passing in the params array to the method. Later I attempted a Map and String[] array.

Object[] params = new Object[] { "user", "username" };

So my questions are:

  1. What is the first statement (Python code) actually passing in to the method? What data type is the method looking for?
  2. And, how would I call the same method using Java syntax?

If you're able to answer the first one, I can probably answer the second question myself.

I've been able to connect to the aforementioned API using a Python script. I've also been able to access XML-RPC methods that don't require any parameters using Java. The problem is that any methods that DO require a parameter, I can't use. Every parameter I try is not recognised.

Thanks for your time.

Edited 6 Years Ago by leiger: n/a

I'm using Java and the Apache XML-RPC libraries, to access an XML-RPC API.

The backend of the API is written in Python and therefore the methods conform to that language (seems a bit strange to me when an API is meant to be accessible by all languages).

From what I've read so far Jython won't help me because I'm not using any local Python code at all - the Python code is all on another server, behind the API. Or is that the problem... and I should be using Jython? I'll have another look at it now...

Solved the problem. The Apache XML-RPC libraries only accepted a List and Object[] ... so I was trying to explicitly cast to Object[] instead, and was getting problems with that.

This worked (passing in a Hashtable, inserted into an Object[]), as it is passing in an Object[] array as the parameter... and the method accepted it:

// Create the Object[] params
Object[] params = new Object[] { null };
Hashtable ht = new Hashtable();
ht.put("user", "username");
params[0] = ht;
// Pass 'params' to the method
// ...

I blame my own inexperience for this. At least I won't make the same mistake again. :)

THEREFORE... not a Python problem after all. I'm marking this thread as solved though. Thanks for your reply tonyjv!

This question has already been answered. Start a new discussion instead.