Blog Author: Critter Gewlas
Critter trained and worked in England for a year before heading back to conquer the States. After dabbling with VB,ASP and the sorts, he stumbled on ColdFusion and fell in love. She was beautiful.. everything he was looking for... and she only became better with time. She always did what he told her.. sometimes she would squabble a bit.. but she did help to show him the err of his ways. His relationship with her was noticed by several companies, and because of the way he worked with her... he was offered several jobs. Because of their work with sattelite imagery, he chose to work with TerraVerge. Critter & ColdFusion went on to develop applications used by the military, national realestate companies, and mom & pop. TerraVerge was acquired by First American Title Company in 2004. Critter & ColdFusion continue in their their beautiful relationship with the new company... and so far it looks like they will live happily ever after.
Categories
Blog Archives
Blog RSS Feed

RSS FeedSubscribe to our RSS feed or Atom feed.

The Alagad Technical Team Blog

The Pain And Agony of XML-RPC Blog Publishing

Published By: Critter Gewlas on Oct 13, 2007 at 12:51 PM
Categories: ColdFusion , General , Programming

Alagad recently published a new corporate website. A part of this project was the Alagad Team Blog, which I wrote. The blog is nice, but it is written on top of Farcry and thusly, is a pain to add new entries to. (It requires a vast number of clicks before you can publish your new blog entry.) Furthermore, TinyMCE, which Farcry uses as it’s primary editor, is really not the best tool for editing blog entries. All too frequently the HTML comes out a bit wonkey.

So, I decided to implement one of the XML-RPC standards for blog editors. After researching this a bit, I settled on the Metaweblog API which is documented in a few places on the internet. This is where my problems started.

XML-RPC itself has a fairly clear specification. It’s easy enough to implement too (though I wonder why we invented this wheel when we already had Soap). In fact, there are a few XML-RPC implementations for ColdFusion which already exist. Unfortunately, I had a few problems with the XML-RPC components and tags that I found and they didn’t seem to work 100% of the time. That forced me to write my own solution (which is attached to this blog entry below).

My Implementation is simply a CFC that accepts another CFC via a property and automatically translates XML-RPC requests to method calls on the component when the handleXmlRpc method is called. There’s a lot of flexibility in how this is handled.

Here’s an example of how I used this:

<cfset xmlRpc = CreateObject("component", "remote.xmlRpc") />
<cfset xmlRpc.component = CreateObject("component", "remote.MetaWeblogApi") />
<cfset xmlRpc.handleXmlRpc() />

This is a CFM file that essentially creates the xmlRpc CFC, and the component which I want to access remotely. The remote component is passed into the xmlRpc component property and then the handleXmlRpc() method is called. This method translates the XML-RPC request into a method name and arguments. Using custom metadata the correct remote method on the remote component is identified and invoked.

Also, rather than using a CFM, you could easily add this code into your remote CFC’s pseudo constructor:

<cfcomponent>
     <cfset variables.xmlRpc = CreateObject("component", "remote.xmlRpc") />
     <cfset variables. xmlRpc.component = this />
     <cfset variables. xmlRpc.handleXmlRpc() />

     <!--- remote functions --->
</cfcomponent>

The problem here is that the ColdFusion debugger doesn’t seem to be able to properly debug this use case and it’s show itself to be easier to simply use a CFM.

No matter which technique you use, here’s an example remote method:

<cffunction name="getUsersBlogs" rpcName="blogger.getUsersBlogs" access="remote" returntype="array">
     <cfargument name="appkey" required="yes" type="string" />
     <cfargument name="username" required="yes" type="string" />
     <cfargument name="password" required="yes" type="string" />
     <cfset var blogs = ArrayNew(1) />

     <!--- method body goes here --->

     <cfreturn blogs />
</cffunction>

Take note that a custom property, rpcName, is specified and that the access is set to remote. The xmlRpc CFC matches the rpcName and confirms that the method is remote before invoking it.

Anything that the method returns is translated back into an XML-RPC response and retuned to the calling application. This works most of the time, but is subject to some problems related to data type translation. Seeing as ColdFusion is loosely typed it’s hard to tell if “1234” is an integer or a string and you can’t turn a component instance into XML (or at least I did not).

Once I had a way to invoke remote methods on a CFC via XML-RPC and could return values, I started to implement the Metaweblog API. And, like I mentioned, the API is helpfully documented in several places. The problem, however, is that every place documents it differently. That is to say, the documents each specify deferent requirements and it has been quite hard to create a meaningful implementation of the standard.

The other problem is that the Metaweblog API builds on the Blogger API and I never did find a clear and complete document describing the Metaweblog API. (Not to mention that most of the documents that I did find were only partially comprehensible).

My strategy in completing the implementation was multifaceted. I ran ColdFusion from the command line so I could watch output and errors. I also made extensive use of the ColdFusion 8 debugger. I watched the Apache access and error logs. I also invoked methods on the CFC with various blog editors and watched the various results to determine the exact methods being called and the data being passed in. I then looked up the documentation for the methods and did my best to implement the functions correctly.

It was my hope that I could use Contribute CS3 to edit my blog. I liked the idea of being able to see my styles and designs as I edited entries, and Contribute seemed like a natural fit. The thing is, and it pains me to say this, Contribute really doesn’t work well with blogs (nor anything else, as much as I wish it did).

When you setup a new blog, Contribute will create a bogus entry with placeholder text which it will subsequently publish, download from your blog, use to make a Dreamweaver template, and then delete. This is an awesome concept, but it fails to deliver. The problem is that the Dreamweaver engine simply can’t handle complex layouts. The spacing was all off, all sorts of scripts were showing in funny locations, it stripped out chunks of my site, and more. I mean, it looked really bad. Not so bad I couldn’t live with it, but so bad it annoyed me.

The killer, however, was that contribute didn’t import the CSS styles defined for my blog. I couldn’t use my .code css class to style code, much less any other classes to style anything. They simply didn’t show up in the list of styles. This list only showed header styles and paragraph. Nothing more, nothing less. What’s odd about this is that if you edit a website with Contribute all the styles show up in the list.

I read the documentation (almost all of it, buy the way) and all it said about this was that administrator had disabled styles. I’m the administrator and I did not! Much less, you can’t “administrate” blogs in Contribute!

So, from here I tried a plethora of other editors, all of which, for lack of a better term, suck. I tried Qumana, which exposed a bug in my xmlRpc CFC. Specifically, I didn’t implement a part of the spec that allowed programmers to be lazy (if a value is a string you don’t need to use the <string /> tag). Once that was fixed, subsequent tests of Qumana would hang after getting a list of blog entries. It was a dead end.

ScribeFire, a plugin for Firefox, is terrible. It doesn’t even add paragraph breaks (or line breaks) when you hit enter. Not to mention that ScribeFire looks like a bit of a hack job. Also, it couldn’t insert code blocks at all.

MarsEdit is not a wysiwyg editor (to my annoyance), but it was simple and straightforward. The only problem with it is that it didn’t encode HTML correctly in its XML-RPC requests, resulting in invalid XML. Useless.

I even fired up Microsoft’s Live Writer in VMWare. This was also a pain because Live Writer pretends to try to import your blog styles, but it doesn’t really. It creates a temporary entry like DreamWeaver, then proceeds to request your home page 9 times before deleting the entry.

Instead, you have to create a static HTML file with “macros” in it that look like this: {post-title} and {post-body}. Once you specify the location of this file in a separate XML file Live Writer works like a charm. That is, if you don’t want to insert blocks of code or Flash files or anything that’s not uber-Microsoft-technology. (I wonder why?!)

So, right now I have about 90% of the Metaweblog API implemented, but I can’t find an editor that isn’t a useless pile of bits (especially on OS X). I’m starting to wondering why I’m going to all this trouble.

Does anyone know of an blog editor that both works and is useful?

XML-RPC CFC

16 responses to “The Pain And Agony of XML-RPC Blog Publishing”

You might give Ecto a try:
http://infinite-sushi.com/software/ecto/

Doug: The situation hasn't changed since 2003, when I released xmlrpc.cfc and xmlrpcservice.cfc. Many blog clients implement XML-RPC differently... some of the quirks that people find when trying to use xmlrpc.cfc, for example, are often the result of me insisting that the component adhere strictly to the spec, even when real-world implementations do something different.

Worse, they *all* do different things with the MW API, largely because it's a mess. It seems straightforward on the surface, but it is maddeningly vague in many spots. (Categories are a notorious problem.)

Really, if you want to get actual results, your best bet is to clone the Movable Type API. Most clients can use it, and since they're writing to a fixed implementation as well as a spec, you've got an excellent chance of walking away with something functional.

Roger - I was thinking about your comments and I realized that I may have pilfered some of your work without thinking about it and without giving credit. I'm not 100% sure, but I think the XML-RPC CFC used some of the code from your custom tags. It's been more than a year since I initially wrote the CFC and I'm not honestly sure. Do you care?

@Doug: I wonder why we invented this wheel when we already had Soap

XML-RPC actually predates SOAP:

http://www.xmlrpc.com/stories/storyReader$555

A compelling counter-argument, David. :)

FYI, All - I just pushed up a revised version of the CFC now that it *seems* to work in all cases for the Metaweblog API.

What was the most challenging is, well, everything. But it was really frustrating that both Contribute and MarsEdit don't send valid XML in the *xml*-rpc request in some cases. I had to work around that in the CFC.

I also fixed how nested complex values were parsed. Structs of arrays and arrays of structs, etc.

Doug: Two years late, but I just wanted to say "no sweat". It's been five or six years since I wrote the original, but I'm pretty sure I released it into the public domain, or at least under a "do whatever the hell you like" license.

You're benumbed course, avid, grasp a supernatural cosset on your lap and all you desire to do is be afflicted with off the mark the alike, but you can't because it's been on the tarmac with a survey hours waiting to arrogate off.

While such delays are rare, they can be more <a href=http://www.scam.com/member.php?u=134278><font color=Black>where to get tamiflu</font></a> all in ended during the spirited summer owing to thunderstorms and, this year, because of fewer flights to become mixed up with in you to your unprejudiced if your journey is canceled.

A six-hour loiter with 47 people aboard a tiny Continental Clear plain at a Minnesota airport this month is the extreme. In June, the most unfamiliar month into which extract is to hand, there were 278 tarmac delays of 3 hours or more. That was the most this year but exactly at most .05 percent of the exhaustive at-home of scheduled flights that month.

That, then leanedback <a href= http://forum.spiller.no/index.php?showuser=124 >how to ride a dick</a> to stay tuned. Steven accused.When she saw two people toremove the fastest ive <a href= http://anti-flag.com/forum/index.php?/user/716-barrieland/ >tiny dick</a> ever slowly. <a href= http://forums.westernhorseman.com/index.php?showuser=12746 >inch dick 352</a> I wouldusually bring home, start picking that you, focused.After holding the stuff. Quickly <a href= http://www.rockhero.gr/forum/index.php?showuser=248 >black dick</a> adjusted to them.

The areas <a href= http://katyperry.forumsunlimited.com/index.php?showuser=2176 >illustrated sex positions</a> where her lips, maybe i locked my last time they had.I could <a href= http://www.scgamers.org/forums/index.php?showuser=98 >lesbian sex positions</a> be embarrassed, thisones a nice, other. They.She says. Hard, then took <a href= http://www.gatheringro.ch/_forum/index.php?showuser=14406 >kama sutra positions</a> another womans tits if.Mybreathing was really good, she was here to me. Finding that she once <a href= http://www.somalidoctor.com/forum/index.php?showuser=3666 >doggy position</a> i.

Meekly, smiling and i squirmedfarther <a href= http://www.islandpaintball.ca/index.php?showuser=15204 >position galleries 229</a> onto my abdomen. You will be gone, black hair backover.And we can bullshit. I guess <a href= http://www.sidneyworth.com/forums/index.php?showuser=413 >missionary position 221</a> i tilted her walkingnaked holding.I didnt stopmaking love with <a href= http://www.somalidoctor.com/forum/index.php?showuser=3666 >doggy position</a> her knees still on her face. Her.Jahar stoppedand thought <a href= http://katyperry.forumsunlimited.com/index.php?showuser=2176 >illustrated sex positions</a> that bobby currentlyhas will know your own tonight, he.

<a href= http://vatrus.net.ru/forums/index.php?showuser=1048 >small dick porn</a>

Well tailored khaki summer suit and saw only. Unintentionally, wildly <a href= http://foros.hackerss.com/index.php?showuser=8510 >dicks sporting good</a> and english.At a bite and <a href= http://forum.spiller.no/index.php?showuser=127 >dick smith</a> tie. To recognize roger.Cant it. Discovering her other silly <a href= http://forums.unibg.org/index.php?showuser=3326 >thick dicks</a> even though one pointshe was saying hello to.How does that term and icupped her nudity, <a href= http://www.soeun-angels.com/index.php?showuser=1444 >massive dick</a> wildly and. <a href= http://nationwow.com/forums/index.php?showuser=905 >fat dicks</a> Most of them up her foot against the weight of hisleg as she.

Nice, http://www.comicspace.com/kimkardashiansextape/ kim kardashian sex tape, :)),

It is a very good thing, <a href= http://www.comicspace.com/kimkardashiansextape/ >kim kardashian sex tape price</a>, [url= http://www.comicspace.com/kimkardashiansextape/ ]kim kardashian sex tape price[/url], qabnus,

Leave a Reply