I have imported the Apache XML-RPC jar files, and got them working (has taken me all day to figure out how to get it working - so I'm kind of frustrated at the moment ;D) ... but that used the execute(..) method which requires two parameters ... there was no one-parameter version which is what I *think* I need.
NOTE: My code is at the bottom of the post.
I want to access an API by sending it requests and collecting whatever it returns back to me.
The XML-RPC server in question is the one that Wikidot.com makes available to it's users to access their wikis.
The main page introducing the API is here: http://www.wikidot.com/doc:api (despite what it says on that page, the API *is* operational and working - I've confirmed that with Wikidot)
For now, I'd just like to get the system.listMethods() method working, as that takes no parameters and returns a list of the methods that I can use. The reason for me wanting to do this one is because I'm guessing it'll be the easiest to do - it doesn't need any parameters.
That method is mentioned on the page I linked to, along with instructions for how to access and use the API using a Python interactive console. I have successfully accessed the API and used it with Python - but I want to do the same thing with a Java application.
This is what I have so far. I have no idea how to call the system.listMethods() method. So the question I'm asking in this thread is - how do I do that?
RunProgram.java
import java.net.MalformedURLException;
import java.util.Vector;
import java.util.Hashtable;
import org.apache.xmlrpc.*;
import org.xml.*;
public class RunProgram
{
private String user = "****"; //Private info, removed
private String key = "****"; //Private info, removed
private final String server_url = "https://"+user+":"+key+"@www.wikidot.com/xml-rpc-api.php";
public static void main(String[] args)
{
new RunProgram().exe();
}
public void exe()
{
System.out.println("*********************************************");
System.out.println("***** Wikidot API - Java Program ************");
System.out.println("*********************************************");
try
{
// Create an object to represent the server
XmlRpcClient myServer = new XmlRpcClient(server_url);
// TODO: I want to call the method "system.listMethods()"
// *** Here, I'd like to call system.listMethods() ***
// myServer.system.listMethods() doesn't work ;-)
}
catch (Exception e)
{
System.err.println("JavaClient: " + e.toString());
}
System.out.println("REACHED END OF PROGRAM");
}
}
I have removed the username and API key for security reasons, but I can assure you that the username/key combination I am using is correct as it worked with Python.
Note: Keep in mind that I am new to everything to do with XML-RPC, which probably explains the difficulty I had in getting this far. Something that seems obvious to you may not be so obvious to me.