<?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>Wed, 03 Mar 2010 13:24:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</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[<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;">
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-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://indiwiz.com/2008/11/20/metaweblog-api-in-java/&amp;title=MetaWeblog+API+in+Java" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://indiwiz.com/2008/11/20/metaweblog-api-in-java/&amp;title=MetaWeblog+API+in+Java" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://indiwiz.com/2008/11/20/metaweblog-api-in-java/&amp;title=MetaWeblog+API+in+Java&amp;desc=Recently%20we%20were%20assigned%20with%20the%20task%20of%20writing%20code%20to%20remotely%20insert%20an%20entry%20to%20a%20blog.%20And%20we%20had%20to%20select%20the%20Blogging%20software.%20So%20we%20started%20with%20the%20search%20for%20a%20blogging%20software%20which%20exposed%20its%20API.%20To%20our%20amazement%2C%20we%20found%20XML-RPC%20ruling%20the%20blogging%20API%20world.%20And%20one%20software%20i" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://indiwiz.com/2008/11/20/metaweblog-api-in-java/&amp;t=MetaWeblog+API+in+Java" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://indiwiz.com/2008/11/20/metaweblog-api-in-java/&amp;title=MetaWeblog+API+in+Java&amp;summary=Recently%20we%20were%20assigned%20with%20the%20task%20of%20writing%20code%20to%20remotely%20insert%20an%20entry%20to%20a%20blog.%20And%20we%20had%20to%20select%20the%20Blogging%20software.%20So%20we%20started%20with%20the%20search%20for%20a%20blogging%20software%20which%20exposed%20its%20API.%20To%20our%20amazement%2C%20we%20found%20XML-RPC%20ruling%20the%20blogging%20API%20world.%20And%20one%20software%20i&amp;source=indiWiz.com" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://indiwiz.com/2008/11/20/metaweblog-api-in-java/&amp;title=MetaWeblog+API+in+Java" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2008/11/20/metaweblog-api-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
