Archive for the 'Web Development' Category

Authorize.net recurring billing API CFC

Saturday, August 18th, 2007

A few weeks ago I had to interface to Authorize.net’s recurring billing API. This is a new API they released early this year. Prior to this, if you wanted a recurring billing subscription setup, you had to log into their site and set it up manually.

When I went to begin coding I searched high and low for an existing custom tag or cfc, but did not find any. So now that mine is complete, I’ve posted it on RiaForge.

ColdFusion CFC for Authorize.net recurring billing API

There is a README file in the zip archive that has fairly detailed instructions, but here are the basics:
(more…)

Cleaning up those funny characters on an XML web service result

Monday, July 9th, 2007

Or - Resolving the ColdFusion Content is not allowed in prolog Error.

If you’ve tried to consume web services with ColdFusion, you may have run into this issue when attempting to use the returned XML. I’ve seen this crop up when simply pulling in an RSS feed as well. Often there are some strange characters at the beginning of the XML response. We can see the problem if we use Firefox to browse to the Authorize.net web service:

Firefox BOM error
(more…)

Case sensitive comparisons in SQL

Tuesday, July 3rd, 2007

We had a need to do a case sensitive SQL comparison this week. As part of a login process a user is prompted for an answer to their security question. Now I really don’t think forcing users to enter their employer’s name in the exact case does anything to keep out hackers, but the client wanted it done this way.

Of course we could pull the values into ColdFusion and do a case sensitive comparison with Compare(). But the code was already setup to do the comparison at the SQL level, which is usually a better idea anyway if it can be done.

There are several ways to tell MS SQL to do a case sensitive comparison. (more…)

Providing feedback when forcing a refresh of the Application scope

Monday, June 18th, 2007

When building an application that uses an Application.cfc file, many times the OnApplicationStart() method is used to initialize Application scope variables.

Since this method is only called once until the next server restart, its safe to set your Application variables here without using cflock tags. A common implementation may look like this:

<cffunction name="onApplicationStart" returntype="boolean">
	<cfset Application.dsn = "myDSN">
	<cfset Application.smtpserver = "localhost">
</cffunction>

But what happens when you need to change one of those variables? For example if you change the Application.smtpserver value to “newhost.com”, and save the file, Application.smtpserver will still be set to localhost. Restarting the ColdFusion server will force the OnApplicationStart() method to be called again, thus loading in your new value, but that is a little drastic.
(more…)

Introduction to ColdFusion presentation

Tuesday, June 5th, 2007

Tonight I gave an “Intro to ColdFusion” presentation at the Omaha Dynamic Language Users Group. As promised, here are the links from my Resources slides. The full presentation is also available: Open Office (1194Kb), PDF (560Kb)

If you can make it to a Scorpio Tour event - Do it!

Tuesday, May 1st, 2007

Tonight we had Adam Lehman from Adobe speak to our CFUG about Scorpio. It was very impressive! They’ve truly done an excellent job at making this a ‘must have’ upgrade. The UI tools, server monitoring, image manipulation, presentation generation, the list goes on. It was just one amazing feature after another. And I can finally use var++ to increment a variable! I have been waiting for this since I started using ColdFusion 4.5.

You can find the Scorpio Tour events on Adobe’s website: http://www.adobe.com/products/coldfusion/events/

Problems installing the ColdFusion connector on Linux/Apache

Thursday, April 5th, 2007

Some people have encountered problems during the ColdFusion MX 7 install on Linux/Apache. When you first start the ColdFusion server, you may see something like this:

Configuring the web server connector (Launched on the first run of the ColdFusion MX 7 start script)
Running apache connector wizard...
=======================================
There was an error while running the connector wizard
Connector installation was not successful

(more…)

SQL ‘UNION’ queries automatically filter out duplicates

Monday, March 26th, 2007

Did you know that in MS SQL and MySQL, a UNION query will automatically filter out duplicate records between the tables that are being unioned?

I ran into this on an email tool I was working on. The client wanted to email users that had recently signed up for either of two different services. So I did a UNION between the two tables to pull all the users into one query that I could loop through. But for some reason, my test user that was in both tables (but with the same name and email address) was only showing up once. I had expected to need to filter out duplicates myself, and I was puzzled as to why both users weren’t showing up. Here is the query:
(more…)

Programatically finding the ColdFusion installation and mail spool directories

Sunday, March 18th, 2007

I am currently working with a client that sends large amounts of mail using ColdFusion. They are having a few problems, and I am going to be doing some optimizations to improve their mail delivery. One of the things we are going to do involves monitoring the number of messages in the ColdFusion spooler directory that are waiting to be handed off to the SMTP server. This involves looking at the files in the ColdFusion spool directory. I did not want to hard code the path to the spool directory, because it may change between production and development machines, and the path may also change when ColdFusion is upgraded.

It is possible to find the spooler directory programatically. My first thought was to look in the adminapi. No luck there. But digging around in the ColdFusion ServiceFactory java class lead me to my answer:

<cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
<cfset MailSpoolService = sFactory.mailSpoolService>

<cfoutput>#MailSpoolService.getSettings().spooldir#</cfoutput>
(more…)

Using the Java StringBuffer class ColdFusion - faster CSV files

Wednesday, March 7th, 2007

I recently wrote a routine to export a client’s newsletter subscribers as a CSV file. There are a little over 7000 records in the database now and that is expected to increase at a steady pace. I have been wanting a good reason to reach into Java and do some fancy string manipulation, as I’ve read it can be quite a bit faster than in native CFML. So this looked like a perfect chance to try it. Here’s my first take in plain old CF. I had some additional quote and comma checking in there but I’ve left it out for readability.
(more…)