JournURL powered

Big Damn Heroes (Tech)


Blog Info

Navigation

<< March 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 31      

Recent Entries

Alternative Formats

Search

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] category: Staff
related topics: (XML-RPC) (SOAP) (webservices) (ColdFusion MX) (CFMX)

return to index