Flex and ColdFusion Services
If you were asked to create a cutting edge, feature-rich, easy-to-use website, what technology would you use to create it? If you said "Flex," then you are off to a good start. Not only does Flex offer a rapid development environment and come packaged with many of the UI components that you need for any application, but it also offers ways to communicate with outside resources. Why does communicating with outside resources matter? It matters because the one thing that Flex does not offer is any kind of server-side technology. This is because Flex was solely created and intended for the creation of client-side applications. So though your Flex application can have the ability to process and manipulate data, that is pretty much where its data functionality ends. Flex on its own has no way to communicate with a mail server, create documents, or even write data to the server’s file system (AIR does have this ability but only for the user’s machine and not for a centralized server that everyone can access). If there were no way for Flex to communicate with a server-side technology that could offer this functionality, then it would not be possible to create the awe-inspiring applications that we have on the internet today.
So the question is: what should you do with the data that your newly created Flex application has gathered? Using the RemoteObject, httpservice, or webservice tags, you can communicate with a server-side scripting language such as .NET, PHP, or Java, sending data via post commands or Soap calls and receiving data via Soap responses or XML. This is all well and good, but how would the server-side script be created? Even though your manager thinks that because you know ActionScript you know all the other languages, that might not actually be the case. What if you don’t know these other languages? Should you try and learn them or hire a freelancer, just so you can have your application send out emails? Well, with the introduction of ColdFusion 9, you will no longer need to worry about that problem anymore.
With the recent release of ColdFusion 9, Flex, as well as other 3rd party technologies, now has direct access to some of the core services that ColdFusion uses. Since Adobe purchased Macromedia in 2005, ColdFusion has been using the same image and PDF technologies that originally put Adobe on the map. With access to these services, developers who do not know how to write a line of ColdFusion will still be able to create high quality images and PDFs. The introduction of ColdFusion as a Service (CFAAS) allows 3rd party technologies access to the following ColdFusion proxy ActionScript Classes:
- Config (Configures the application for using ColdFusion Services)
- Util
(Includes file upload support)
- Chart (Charting functionality)
- Document (PDF Creation)
- Image (Image Creation and Manipulation)
- Mail (Email Creation and Sending)
- PDF (PDF manipulation)
- POP (Email Retrieval through POP3 Mail Server)
Installing ColdFusion 9
The first thing you need to do to install ColdFusion 9 is download a copy from the Adobe Labs website.
Once the download is completed, follow the on-screen prompts.
Most of the screens are self explanatory, but let’s just review a couple that could trip you up.
When
you get to the “Install Type Step" (figure 1), you are asked to either
provide a serial number or choose a 30-day trial or developer edition.
Select the developer edition. The developer edition will install a
fully functional copy of ColdFusion that can only be accessed locally.
The “Installer Configuration Step” (figure 2) is where you can choose how ColdFusion will be installed on your machine. For now choose the default server configuration option. All examples below will be assuming that this was your configuration choice.
ColdFusion comes pre-packaged with a built-in web server. If you have apache or IIS installed on your machine you will be able to choose to run ColdFusion through these during the “Configure Web Servers Step” (figure 3), but for simplicity’s sake, select the built-in web server option.
Once
all the steps have been completed, ColdFusion 9 will be installed on
your computer. If you selected all the default settings during the
installation process, you will have the following server information:
Web Root: C:\ColdFusion9\www root OR /applications/ColdFusion9/wwwroot/
Server Root: http://localhost:8500/ OR http://127.0.0.1:8500
ColdFusion Administrator: {server root}/cfide/administrator/
For
those of you who want to experiment with ColdFusion 9 but do not wish
to install the server on your local machine, you can get free
ColdFusion 9 hosting from a number of ColdFusion hosting companies.
As
we don’t want everybody to be able to access the services on your
machine, it is necessary to create a user account to access the
services.
In the ColdFusion Administrator go to the “User
Manager” page under the “Security” section. Click “add user” and
provide a username and password. Remember the details, as you will
need them later. Whenever you see “Your Username” or “Your Password”
in the code examples, put this information in. Before clicking “add
user,” go to the “Exposed Services” section and move all the services
from “Prohibited Services” to “Allowed Services.” Don’t worry, things
are still secure, because the services are also restricted by IP
address. Click on “add user” to finally add the user.
Now that
the user is added, you need to click on “Allowed IP Addresses,” which
is also under the “Security” section. In the IP address box add the IP
127.0.0.1. If you do not have ColdFusion installed on your machine,
you will need to add your external IP address. You are now ready to use
CFAAS.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




