Accessing ColdFusion
Services From Flex
Applications

Matt Gifford aka @coldfumonkeh



Adobe ColdFusion Developer Week 2011
Who?
Lead RIA Developer
Adobe Community Professional
User Group Manager - Hertfordshire, UK
Author
Coffee Lover


@coldfumonkeh
www.mattgifford.co.uk

www.fuzzyorange.co.uk
Integrating ColdFusion services into non-
        ColdFusion systems and applications



What?   Utilise powerful features whilst minimising
        coding and maximising functionality

        Improving workflow and developer
        collaboration across language divides
Because ColdFusion is incredibly powerful


Why?   Rapid Application Development

       It’s awesome fun
COLDFUSION CODE NINJAS // ALL OF YOU
Object-relational mapping (ORM)

             Enhanced Document Manipulation

             Enhanced AJAX controls


CF9          Sharepoint integration (portals)


gave us...   ColdFusion Builder

             Exposed Service Layer (CFaaS)

             and much more...
Remote Services
LET’S DEMONSTRATE // DATA CENTRIC DEVELOPMENT
Exposed Service Layer
WHAT IS AVAILABLE? // EXPOSED FUNCTIONALITY
ColdFusion
as a Service
(or how to share the awesome-ness with
other developers and other languages)
http://[server]:[port]/CFIDE/services/

   http://localhost:8500/CFIDE/services/mail.cfc?wsdl

   http://localhost:8500/CFIDE/services/document.cfc?wsdl

   http://localhost:8500/CFIDE/services/chart.cfc?wsdl




ACCESSING SERVICES // WEB SERVICE
Chart             Mail
           generate          send

           Document          PDF
           generate          addWatermark
                             convertArrayOfStructToPDFPageDetailArray [private]
                             deletepages
           Image             extractImage
           AddBorder
                             extractPages
           batchOperation
                             extractText
           Blur
                             getInfo
           Crop
                             mergeFiles
           Flip
                             mergespecificpages
           GetEXIFMetaData
                             processDDX
           GetEXIFTAG
                             protect
           GetHeight
                             removewatermark
           GetIPTCMetaData
                             setinfo
           GetIPTCTag
                             thumbnail
           GetWidth
           GrayScale
           Info              POP
           Negative          delete
           Overlay           getAll
           Resize            getHeaderOnly
           Rotate
           ScaletoFit
           Sharpen
           Shear




AVAILABLE SERVICES // WHAT YOU CAN DO WITH IT
Restricted
Access
to exposed services through the
ColdFusion Administrator
ActionScript Proxy Classes
ColdFusion:


        <cfmail to="requests@guitar-hero.com"
        	 from="me@my_email_address.com"
        	 subject="More Kenny Loggins" />


AS Proxy in Flex:


        <cf:Mail to="requests@guitar-hero.com"
        	 from="me@my_email_address.com"
        	 subject="More Kenny Loggins" />
Import the cfservices.swc file (from ColdFusion 9 install):

                             typically in /CFIDE/scripts/AIR/ directory


   Add ColdFusion namespace to your Flex application

                             xmlns:cf=”coldfusion.service.mxml.*”


   Write some code

                             That bit’s over to you...




HOW EASY IS IT? // VERY
LET’S DEMONSTRATE // BUILDING AN APPLICATION
USEFUL REMINDERS

  ColdFusion Connection:

                      <cf:Config id="conf"
                      	   	    cfServer="localhost"
                      	   	    cfPort="8500"
                      	   	    serviceUserName="demoUser"
                      	   	    servicePassword="demoPassword" />



        Define a Method:
                      <cf:Image id="getImageInfo"
                      	   	    action="info"
                      	   	    source="{dragImage.source}"
                      	   	    result="imageInfoResult(event)"
                      	   	    fault="onFault(event)" />	



  Execute (in a nice way):
                             getImageInfo.execute();
STRESS-FREE UPLOADS // UTIL CLASS MAGIC
USEFUL REMINDERS

  Upload URL:
   uploadUrl.url = "http://"+conf.cfServer+":"+conf.cfPort+"/"+Util.UPLOAD_URL;
   uploadUrl.method = "POST";
   uploadUrl.contentType = "multipart/form-data";




  Util Class Generates:

   http://localhost:8500/CFIDE/services/upload.cfc?METHOD=uploadForm




  Get Remote Location:

   uploadedFileUrl = Util.extractURLFromUploadResponse(event.data.toString());
WHY SHOULD YOU CARE? // BECAUSE YOU’RE AWESOME
Full code on github:


           https://github.com/coldfumonkeh/ColdFusion-Dev-Week-Demos




 CFaaS method cheat sheet:



           http://www.mattgifford.co.uk/updated-cfaas-method-cheat-sheet




TRY IT YOURSELF // THINGS TO HELP YOU
Accessing ColdFusion Services From Flex Applications
Matt Gifford aka @coldfumonkeh        Adobe ColdFusion Developer Week 2011

Accessing ColdFusion Services From Flex Applications

  • 1.
    Accessing ColdFusion Services FromFlex Applications Matt Gifford aka @coldfumonkeh Adobe ColdFusion Developer Week 2011
  • 2.
    Who? Lead RIA Developer AdobeCommunity Professional User Group Manager - Hertfordshire, UK Author Coffee Lover @coldfumonkeh www.mattgifford.co.uk www.fuzzyorange.co.uk
  • 3.
    Integrating ColdFusion servicesinto non- ColdFusion systems and applications What? Utilise powerful features whilst minimising coding and maximising functionality Improving workflow and developer collaboration across language divides
  • 4.
    Because ColdFusion isincredibly powerful Why? Rapid Application Development It’s awesome fun
  • 5.
  • 6.
    Object-relational mapping (ORM) Enhanced Document Manipulation Enhanced AJAX controls CF9 Sharepoint integration (portals) gave us... ColdFusion Builder Exposed Service Layer (CFaaS) and much more...
  • 7.
  • 10.
    LET’S DEMONSTRATE //DATA CENTRIC DEVELOPMENT
  • 11.
  • 12.
    WHAT IS AVAILABLE?// EXPOSED FUNCTIONALITY
  • 13.
    ColdFusion as a Service (orhow to share the awesome-ness with other developers and other languages)
  • 14.
    http://[server]:[port]/CFIDE/services/ http://localhost:8500/CFIDE/services/mail.cfc?wsdl http://localhost:8500/CFIDE/services/document.cfc?wsdl http://localhost:8500/CFIDE/services/chart.cfc?wsdl ACCESSING SERVICES // WEB SERVICE
  • 15.
    Chart Mail generate send Document PDF generate addWatermark convertArrayOfStructToPDFPageDetailArray [private] deletepages Image extractImage AddBorder extractPages batchOperation extractText Blur getInfo Crop mergeFiles Flip mergespecificpages GetEXIFMetaData processDDX GetEXIFTAG protect GetHeight removewatermark GetIPTCMetaData setinfo GetIPTCTag thumbnail GetWidth GrayScale Info POP Negative delete Overlay getAll Resize getHeaderOnly Rotate ScaletoFit Sharpen Shear AVAILABLE SERVICES // WHAT YOU CAN DO WITH IT
  • 16.
    Restricted Access to exposed servicesthrough the ColdFusion Administrator
  • 17.
  • 18.
    ColdFusion: <cfmail to="requests@guitar-hero.com" from="me@my_email_address.com" subject="More Kenny Loggins" /> AS Proxy in Flex: <cf:Mail to="requests@guitar-hero.com" from="me@my_email_address.com" subject="More Kenny Loggins" />
  • 19.
    Import the cfservices.swcfile (from ColdFusion 9 install): typically in /CFIDE/scripts/AIR/ directory Add ColdFusion namespace to your Flex application xmlns:cf=”coldfusion.service.mxml.*” Write some code That bit’s over to you... HOW EASY IS IT? // VERY
  • 20.
    LET’S DEMONSTRATE //BUILDING AN APPLICATION
  • 21.
    USEFUL REMINDERS ColdFusion Connection: <cf:Config id="conf" cfServer="localhost" cfPort="8500" serviceUserName="demoUser" servicePassword="demoPassword" /> Define a Method: <cf:Image id="getImageInfo" action="info" source="{dragImage.source}" result="imageInfoResult(event)" fault="onFault(event)" /> Execute (in a nice way): getImageInfo.execute();
  • 22.
    STRESS-FREE UPLOADS //UTIL CLASS MAGIC
  • 23.
    USEFUL REMINDERS Upload URL: uploadUrl.url = "http://"+conf.cfServer+":"+conf.cfPort+"/"+Util.UPLOAD_URL; uploadUrl.method = "POST"; uploadUrl.contentType = "multipart/form-data"; Util Class Generates: http://localhost:8500/CFIDE/services/upload.cfc?METHOD=uploadForm Get Remote Location: uploadedFileUrl = Util.extractURLFromUploadResponse(event.data.toString());
  • 24.
    WHY SHOULD YOUCARE? // BECAUSE YOU’RE AWESOME
  • 25.
    Full code ongithub: https://github.com/coldfumonkeh/ColdFusion-Dev-Week-Demos CFaaS method cheat sheet: http://www.mattgifford.co.uk/updated-cfaas-method-cheat-sheet TRY IT YOURSELF // THINGS TO HELP YOU
  • 26.
    Accessing ColdFusion ServicesFrom Flex Applications Matt Gifford aka @coldfumonkeh Adobe ColdFusion Developer Week 2011