<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>indiWiz.com &#187; xml-rpc</title>
	<atom:link href="http://indiwiz.com/tag/xml-rpc/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiwiz.com</link>
	<description>Subhash&#039;s Tech Log</description>
	<lastBuildDate>Sun, 29 Apr 2012 15:11:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MetaWeblog API in Java</title>
		<link>http://indiwiz.com/2008/11/20/metaweblog-api-in-java/</link>
		<comments>http://indiwiz.com/2008/11/20/metaweblog-api-in-java/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 16:43:18 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[webservice]]></category>
		<category><![CDATA[xml-rpc]]></category>

		<guid isPermaLink="false">http://indiwiz.wordpress.com/?p=28</guid>
		<description><![CDATA[Recently we were assigned with the task of writing code to remotely insert an entry to a blog. And we had to select the Blogging software. So we started with the search for a blogging software which exposed its API. To our amazement, we found XML-RPC ruling the blogging API world. And one software independent [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>Recently we were assigned with the task of writing code to remotely insert an entry to a blog. And we had to select the Blogging software. So we started with the search for a blogging software which exposed its API. To our amazement, we found XML-RPC ruling the blogging API world. And one software independent standard for it is the <a href="http://www.xmlrpc.com/metaWeblogApi">MetaWeblog API</a>.</p>
<p>After selecting the API, we had to find a software supporting this API. This assignment was for a demo we were to show. So we wanted a minimal blogging software with no configuration. We found <a href="http://pebble.sourceforge.net/">Pebble</a> (we used version 2.3.1). This software is cool. Installation is breeze, just put the WAR file in an application server, and you are ready to use it!</p>
<p>Now came the implementation part. I assumed the existence of a Java library implementing this MetaWeblog API. But did not find any. So the next obvious step: use some XML-RPC library in Java to implement the call. I had some bad opinion about <a href="http://ws.apache.org/xmlrpc/">Apache&#8217;s XML-RPC library</a>. I had used it long back ago, and I hated the way it was implemented. Since then I have been using Python to access XML-RPC services. But, this time, the job required use of Java.</p>
<p>So we ventured to the next step: finding an alternative OpenSource Java XML-RPC library. We found <a href="http://rox-xmlrpc.sourceforge.net/">RoX</a>. We were happy because RoX was born out of frustration of using Apache&#8217;s XML-RPC engine. We implemented it. And RoX did not work for Pebble (still not able to figure out if it was a mistake on our part, or RoX really did have a bug). So switched to Apache (version 3.1.1). The 3.x API seems to have been simplified. So finally we wrote:</p>
<pre class="brush: java; title: ; notranslate">
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

...

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(&quot;http://localhost:8080/pebble/xmlrpc/&quot;));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);

// Params needed: blogid, username, password, struct, publish
// First create the fourth parameter, struct:
Map&lt;string, String&gt; m = new HashMap&lt;string, String&gt;();
m.put(&quot;title&quot;, &quot;Hello World &quot; + Calendar.getInstance().toString());
m.put(&quot;link&quot;, &quot;http://www.indiwiz.com/&quot;);
m.put(&quot;description&quot;, &quot;This is the content of the post!&quot;);

Object[] params = new Object[]{&quot;default&quot;, &quot;username&quot;, &quot;password&quot;, m, true};

String ret = (String) client.execute(&quot;metaWeblog.newPost&quot;, params);
System.out.println(ret);
</pre>
<p>And then we delivered our demo!</p>
<div class="shr-publisher-28"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2008/11/20/metaweblog-api-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

