Download redstone xml rpc from source forge:
http://sourceforge.net/projects/xmlrpc/files/%28New%29%20Redstone/
Set classpath to include the jar file.
Enable rpc at http://<wordpress site>/wp-admin/options-writing.php
compile and run the following code:
import redstone.xmlrpc.XmlRpcClient;
import java.util.HashMap;
public class XmlRpcPoster
{
public static void main( String[] args )
{
// Check command-line arguments
if( args.length < 3 )
{
System.out.println( "Usage: java XmlRpcPoster <XML-RPC URL Entry Point> <username> <password>" );
}
else
{
// Get command-line arguments into variables
String sXmlRpcURL = args[0];
String sUsername = args[1];
String sPassword = args[2];
// Hard-coded blog_ID
int blog_ID = 1;
// XML-RPC method
String sXmlRpcMethod = "metaWeblog.newPost";
// We'll hard-code our blog content for now as well
String sContent = "Hello XML-RPC World!";
String sTitle = "Hello XML-RPC Title";
// Create our content struct
HashMap hmContent = new HashMap();
hmContent.put("title", sTitle);
hmContent.put("description", sContent);
// You can specify whether or not you want the blog published immediately
boolean bPublish = true;
// Try block
try
{
// Create the XML-RPC client
XmlRpcClient client = new XmlRpcClient( sXmlRpcURL, false );
// Make our method call
Object token = client.invoke( sXmlRpcMethod, new Object[] { new Integer( blog_ID ), sUsername, sPassword, hmContent, new Boolean( bPublish ) } );
// The return is a String containing the postID
System.out.println( "Posted : " + token.toString() );
}
// Catch exceptions
catch( Exception e )
{
e.printStackTrace( System.err );
}
}
}
}