JournURL powered

Big Damn Heroes (Tech)


Blog Info

Navigation

<< April 2004 >>
S M T W T F S
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  

Recent Entries

Stuff I Read

Alternative Formats

Search

April 01, 2004

ColdFusion, Blogs, and SOAP

I don't think I ever mentioned this publicly, but in addition to JournURL's support for the XML-RPC Metaweblog API, I've also done a basic transform of the API into CFMX-compatible SOAP. It's still experimental, and is only currently supported in a single JournURL community: MXBlogspace.

If you're interested in trying your hand at writing a client app (Flash, for example) that can post and edit JournURL entries, just let me know... we'll get you set up with an account and the info you need.

FWIW, here's the auto-generated documentation for the service.

04-01-2004 12:58:47PM - Permalink - Post Reply - Read Comments [0]

March 17, 2004

xmlrpcservice.cfc

I'm finally getting around to posting this. Please note that, if you're going to make heavy use of this component, I'd suggest picking up a copy of DRK4 from Macromedia. In it, you'll find an article that gets into the details of dealing with XML-RPC in Coldfusion MX, written by yours truly. It isn't a great piece, but it's better than anything you'll find in this blog post.

XMLRPCSERVICE.CFC

  • Purpose:
    To provide near-transparent support for XML-RPC webservices within a standard, SOAP-aware Coldfusion component.
  • What Your Need:
    Coldfusion MX (Updater 3+)
    xmlrpc.cfc
    xmlrpcservice.zip
    (both CFCs should be installed together in the same directory)

Use is very simple. Here's a standard, SOAPy CFC:

<cfcomponent>   
 <cffunction name="setDate" output="false" access="remote">   
  <cfargument name="param1" type="date" required="true">   
  <cfset var myResult = StructNew()>   
  <cfset myResult.message = "the date has been set to #arguments.param1#">   
  <cfset myResult.date = ParseDateTime(arguments.param1)>   
  <cfreturn myResult>   
 </cffunction>   
</cfcomponent>

Here's all you need to change to make that same CFC XML-RPC aware:

<cfcomponent extends="xmlrpcservice">   
 <cffunction name="setDate" output="false" access="remote" xmlRpcAccess="true">   
  <cfargument name="param1" type="date" required="true">   
  <cfset var myResult = StructNew()>   
  <cfset myResult.message = "the date has been set to #arguments.param1#">   
  <cfset myResult.date = ParseDateTime(arguments.param1)>   
  <cfreturn myResult>   
 </cffunction>   
</cfcomponent>

All that changed was the added "extends" attribute on <cfcomponent>, and the addition of an "xmlRpcAccess" attribute on <cffunction>. The big difference is in how the client machine calls the two services:

  • SOAP: http://foo.com/date.cfc?wsdl
  • XML-RPC: http://foo.com/date.cfc?method=xmlrpc
    In this case, the "real" method (setDate) will be passed in the XML-RPC request body, just like any other XML-RPC package.

Note that XML-RPC does not support named params, so xmlrpcservice.cfc will default to naming them things like "arguments.param1", "arguments.param2", and so on. The client can override this behavior by passing in a params argument, which should be a pipe-delimited list of names.

03-17-2004 09:19:48AM - Permalink - Post Reply - Read Comments [1]

October 05, 2003

RSS-Data Parser for ColdFusion MX

It took about an hour to get a (fully?) functional RSS-Data parser working in conjunction with an updated version of my xmlrpc.cfc.

Go ahead and give it a whirl. (Feel free to View Source my blog's RSS feed and copy it into the form.)

NOTE: Yes, I know there is no RSS-Data specification, and yes, this means that I've pulled the format out of my ass. But I think it sticks closely to what Dave has defined in XML-RPC and Jeremy has described.

And for those who want to know how much code it took ...

<cfset test = XmlParse(form.rss)>       
<cfset myobjects = StructNew()>       
<cfset mysdl = XmlSearch(test, "//sdl:variable")>       
<cfloop index="x" from="1" to="#ArrayLen(mysdl)#">       
 <cfset myname = mysdl[x].xmlattributes.id>       
 <cfset myobjects[myname] = mysdl[x]>       
 <cfinvoke component="xmlrpc"      
   method="deserialize"      
   branch="#myobjects[myname]#"      
   namespace="sdl"       
   returnvariable="mytempobject">       
 <cfset myobjects[myname] = mytempobject>       
</cfloop>       
<cfdump var="#myobjects#">       

That's it. Everything else happens in the XML-RPC parser. And the only changes made to the parser was hacking in quickie support for deserializing namespaced elements. Literally five minutes of work.

(Feel free to leave comments and/or questions. Please note that JournURL's comment system prefers that you register, so while you can comment anonymously, your post goes into an invisible moderation queue until I can review it.)

ADDED: Another couple minutes of tuning got rid of some of the cruft in the code, which is now a few lines shorter as a result:

<cfset myobjects = StructNew()>       
<cfset mysdl = XmlSearch(XmlParse(form.rss), "//sdl:variable")>       
<cfloop index="x" from="1" to="#ArrayLen(mysdl)#">          
 <cfinvoke component="xmlrpc"      
   method="deserialize"      
   branch="#mysdl[x]#"      
   namespace="sdl"       
   returnvariable="mytempobject">       
 <cfset myobjects[mysdl[x].xmlattributes.id] = mytempobject>       
</cfloop>       
<cfdump var="#myobjects#">       

10-05-2003 04:12:37PM - Permalink - Post Reply - Read Comments [0]

XMLRPC.CFC v1.2

I've uploaded the latest version of xmlrpc.cfc, my XML-RPC component for ColdFusion MX. If you've been using the 1.0 version, there are a number of changes and bugfixes... if you've been using version 1.1 from Macromedia's Developers Resource Kit 4, the only change is a tweak to the deserialize() method that allows it to handle namespaced elements.

xmlrpc.zip (2488 bytes)

10-05-2003 04:04:23PM - Permalink - Post Reply - Read Comments [0]