Blog

19Jun
2009
ColdFusion Functionality Exposed As Services

Have you ever stopped to think about just how much functionality is baked into ColdFusion? We use <CFQUERY> to work with databases, allowing for highly flexible and dynamic SQL as well as query caching and more, and this is powered by a sophisticated internal engine. We use tags like <CFCHART> and expect charts to be generated and displayed, without every really paying attention to the fact that an entire Java based charting engine is built in and actually doing the heavy lifting. The same is true for <CFPDF>, <CFIMAGE>, <CFSEARCH>, support for SOAP and Web Services, XMPP and JMS integration, and so much more. While most of us focus on CFML the language, the truth is that the bulk of ColdFusion, the majority of what gets installed, is not the language but the extensive array of integrated services, services that are exposed to ColdFusion via CFML tags and functions.

But what if these services could be accessed outside of ColdFusion? If a PHP developer in the next cube over needed to merge PDF files, why couldn't he invoke ColdFusion's PDF manipulation services? If a .NET developer needed to access Microsoft Exchange, why couldn't she use ColdFusion's brilliant Exchange tags (rather than having to write lots and lots of .NET code, and I do mean lots and lots)? What about the Java developer who needs to easily manipulate spreadsheet files without tinkering with low level libraries?

And while we're at it, what about the Flex developer who needs to generate an e-mail message? Flex (well, Flash) has no built in SMTP libraries, and so Flex developers who need to programmatically generate e-mail messages do so by writing code on the server. For ColdFusion developers this means creating a ColdFusion Component which accepts data from a Flex application (likely via an AMF call) and then passes that same data to a <CFMAIL> tag. In other words, code is being written on the server just to be able to pass data from Flex on the client to the <CFMAIL> tag. So why couldn't a Flex developer just invoke <CFMAIL> directly, passing it name=value pairs so it can generate an e-mail?

Well, with the upcoming ColdFusion Centaur, the answer to all of these questions is yes, these are all doable! In ColdFusion Centaur we're exposing lots of those integrated ColdFusion services via AMF (Flash Remoting) and SOAP (Web Services). The PHP, .NET, and Java developers can invoke ColdFusion built-in Web Services, pass in data, and get back results. And the Flex developer can include a ColdFusion SWC file exposing ActionScript classes and MXML tags via simple abstracted AMF calls. Simply include the SWC in your Flash Builder project, define the ColdFusion name space like this:

view plain print about
1<mx:Application xmlns:cf="coldfusion.service.mxml.*">

and you'll have access to CFML tags within your Flex project. For example, to send an e-mail you could use the following:

view plain print about
1<cf:Mail id="cfMail"
2    to="{to.text}"
3    from="{from.text}"
4    subject="{subject.text}"
5    content="{body.text}"
6    type="html"    />

The above code creates an instance of the Mail object and names it "cfMail", and sets to, from, subject, etc., with the values of other Flex objects. To actually send the mail all you'd need is to invoke the following (possibly when a Send button is clicked):

view plain print about
1cfMail.execute();

There is much more to this "ColdFusion as a Service" functionality, including lots more services exposed, and a sophisticated security model.

But the bottom line is that ColdFusion is now poised to become even more valuable to Flex and AIR developers, and now even of value to developers using other platforms and languages.

Related Blog Entries

Comments (9)



  • Adam Tuttle

    Peter Elst posted a video of Ryan Stewart demoing this new feature here: http://www.peterelst.com/blog/2009/06/11/sneak-pee...

    Looks pretty awesome to me!

  • James Lamar

    I think this will really help to gain to support and usage of developers who feel more comfortable writing in other languages. Despite the fact that I love writing in CF I think this will be useful in projects where I'm forced to do ASP.NET or something other than CF.

    This is a great move by Adobe. It's only going to attract more developers.

    Thanks for the insight Ben!

  • Jared Rypka-Hauer

    And with that, a small legion of PHP, Python and Ruby devs all jumped from tall buildings into the killer earth below. Why? Well, mostly because there's not even any *weak* arguments for why any of those are superior backend platforms for Flex or AIR apps. ;)

  • andy matthews

    Ben...Greg talked last night in Nashville about cfspreadsheet (which looks amazing by the way). Is there any thought about exposing this sort of functionality as a service as well? Or can a developer add this as a service on their own?

  • Big Al

    Ben,
    Will this functionality be in the standard version? Or just enterprise?

    #5Posted by Big Al | Jun 19, 2009, 02:37 PM
  • Ben Forta

    Andy, that's still a work in progress.

    Big Al, no decisions about editioning have been made yet. But, I doubt that this would be enterprise only.

    --- Ben

    #6Posted by Ben Forta | Jun 19, 2009, 02:50 PM
  • Dan

    Any idea if you could call CF tags as a service from inside a Visual Force page on the force.com platform?

    #7Posted by Dan | Jun 22, 2009, 04:16 PM
  • Govind

    Where to do we get the SWC file?

    #8Posted by Govind | Jul 14, 2009, 06:13 AM
  • Ben Forta

    In a folder under CFIDE.

    --- Ben

    #9Posted by Ben Forta | Jul 14, 2009, 10:34 AM