Dynamic Image Maps Crash Internet Explorer IE6 & IE7

We have been working on a couple of projects that use dynamic image maps. We had an issue that crashed IE6 and IE7 when a certain combination of links were clicked on. The scenario is that a user is presented with a map of Australia and clicks a state. We take that click, and return a map and imagemap of the state they clicked on. Then you click a region and keep drilling until there are no more maps.

[More]

.NET components via ColdFusion – a practical example with v3 Leisure CABS

We recently came across a project where our client, a holiday listing site, wanted to integrate with a third party information provider. Not a problem we said! It turns out that the .NET webservice was something like we had never seen before. There were no arguments or datatypes, just an input of some XML against a DTD. This meant that instead of passing in a number of arguments, we had to get just one, the XML that would normally be generated by ColdFusion, wrapped in the SOAP envelope and sent.

If you have had any major dealings with webservices in CF then you will know that there is no fine grain control over how CF puts the SOAP packets together. We tried a few different avenues and quickly discovered that passing a datatype of XML to the webservices resulted in CF running XMLParse over the XML we put in. Clearly not the correct result. The next (and our last) option was to look at going around the CF SOAP constructor using Java, but with a lack of skills at the time it didn't seem to be an option.

Enter .NET, and the V3 example app. This came with a dll file that did the SOAP wrapping and took some straight XML from the sample application. It was a long shot but hey, we were out of options. So we took the dll and asked CF to open it as a native object. It works brilliantly. To get inside the dll we used Lutz Reflector to find methods and arguments. CF didn't seem to be able to dump out this information effortlessly.

<!--- connect to the .NET object --->
<cfobject
   type=".NET"
   name="v3assembly.obj"
   class="V3Leisure.CABS.WebServices.Examples.CABSExamplesUI.BLL.#Method#"
   assembly="#application.path#\lib\CABSExamplesUI.BLL.dll"
/>


<!--- build up the info to send to the .NET assembly --->
<cfset v3assembly.uri = JavaCast("string","http://www.au.v3travel.com/CABS.WebServices/SearchServiceAdapters.asmx")>
<cfset v3assembly.xml = JavaCast("string",XMLParse(XML))>
<cfset v3assembly.bool = JavaCast("boolean",true)>

<cftry>
   <!--- return the response from the V3 assembly --->
   <cfreturn XmlParse(v3assembly.obj.SendRequest(v3assembly.uri,v3assembly.xml,v3assembly.bool))>
   <cfcatch>
      <cfthrow type="red5" message="It appears that the ColsFusion 8 .NET integration service is not running.">
   </cfcatch>
</cftry>

Once you have hooked up CF to talk with the DLL, it works much like any other object or CFC. Pass in some variables and receive some back. Rinse, and repeat.

The result, if you can't talk to the .NET asmx webservice in a simple XML format, then you need to bypass CF. Java would be able to handle it in most cases, but where the XML was the SOAP body, or the arguments are defined by a DTD, then one of your best options is to make use of the ColdFusion 8 .NET service. Of course it requires that the provider of the service is able to provide you with a .NET component to accept your XML, and wrap it appropriately for you.

Lutz Reflector – looking into .NET components from the outside

When trying to find out what a DLL does, and what methods it has inside, us ColdFusioneers were at a bit of a loss. There is almost zero experience in this world in our team. Until we came across this very handy tool Lutz Reflector. Simply, it introspects dll files and .NET components for you, giving you information about methods and arguments. On its own this isn't the most help but can give you a leg up when you need it. Most components would come with some documentation, but even that can lack detail.

Here is the highlight blurb from the site:

  • Explore .NET assemblies in an easy-to-understand, natural way
  • Understand the relationships between classes and methods
  • Find where types are instantiated and exposed
  • Check that your code has been correctly obfuscated before release

Get Lutz Reflector from RedGate for free.

Using sshexec from ANT in Eclipse for build files

Following on from other p[osts, we continue to improve our build files for deployment of client sites. Our latest addition is the sshexec task for clients using Linux or a LAMP environment to host their site.

Our build files move the code out of SVN, zip it up, commit the build record back to SVN, and FTP the resulting file to the site. With ssh we can now unzip the file and have ANT do all the work for us.

sshexec is not one of the core tasks in ANT, you can find out about ANT dependacies here. Currently you need jsch.jar 0.1.29 or later from the JCraft Java Secure Channel project.

Place the JAR file into [eclipseroot]\plugins\org.apache.ant_1.7.0.v200803061910\lib directory

Once you have placed your jar file, you need to get Eclipse to load them at runtime. I read somewhere that using the ANT folder above and a simple restart would have Eclipse pick them up, but that didn't work for me.

1. Open Eclipse 2. Window > Preferences 3. Ant > Runtime 4. Ant Home Entries (Default) 5. Click Add External JARs 6. Navigate to [eclipseroot]\plugins\org.apache.ant_1.7.0.v200803061910\lib or wherever you unzipped the jar files 7. Select the jsch.jar file 8. Open > Apply > OK 9. Restart Eclipse

You should now be able to use the following target to make it happen, this example unzips a predefined zip file:

<target name="SSHunzip">
      
   <echo message="Unzipping Zip file" />
   
   <sshexec host="${projectURL}"
      username="${SSH.Username}"
      password="${SSH.Password}"
      trust="true"
      command="unzip -o ${FTP.Development.RemoteLocation}/${projectName}.${build.number}.${svn.info.rev}.zip -d ${FTP.Development.RemoteLocation}"/>

</target>

Using agrep to parse log files

How to use agrep, a windows based version of the linux command line grep tool

This example comes from finding lines related to a message in smartermail log files.

Lets assume we are trying to find an email and track the actions our mail server did for that email. First I am going to filter the logs for the 16/6/2009 and return only the lines for a particular domain.

To do this we copy the days log files into a /tmp directory and run the following:

D:\SmarterMail\Logs\tmp>agrep -k "domain.com" * > d:\smartermail\logs\tmp\out\out.txt

This will give us every line in all the files in the tmp directory relating to domain.com. We can then sift through this manually to find a row relating to the mail we need.

One of these lines looks like this:

2009.06.16-delivery.log: 10:36:11 [25354] Delivery started for webmaster@domain.com at 10:36:11 AM

Notice the [xxxxx] reference number - this is carried through all logs for this particular email, so we can use thet to find all log entries about this mail:

D:\SmarterMail\Logs\tmp>agrep -k "[25354]" * > d:\smartermail\logs\tmp\out\out.txt

this outputs all the lines with [25354] in them to the out.txt file

2009.06.16-delivery.log: 10:36:11 [25354] Delivery started for webmaster@domain.com at 10:36:11 AM
2009.06.16-delivery.log: 10:36:43 [25354] Launching 'C:\Program Files\DKeyEvent\dkeyevent.exe' command line exe.
2009.06.16-delivery.log: 10:36:44 [25354] Command line exe finished.
2009.06.16-delivery.log: 10:36:46 [25354] Starting local delivery to webmaster@domain.com.au
2009.06.16-delivery.log: 10:36:46 [25354] Delivery for webmaster@domain.com to webmaster@domain.com.au has completed (Forwarded Deleted) Filter: None
2009.06.16-delivery.log: 10:36:46 [25354] End delivery to webmaster@domain.com.au

Moving to Windows 7 RC, ColdFusion and Apache

I am bored with Vista, and the Windows 7 RC came along at about the right point in time (The annual Windows reinstall was due), so I decided to take the plunge. It's a bit of a risk for primary work machine, so I prepared everything late on Friday, pulled DVD's for software out, and an XP Pro DVD just in case! By and large it was pretty smooth, but here are the issues I did run in to:

Windows installer could not expand set up files

This was an odd error where the installer started, but sat on 0% expanding for an hour or more, then told me that it could not get the files required. A bit of digging turned up that I should try a burn of the RC ISO file on a different machine, or at a different speed. So I tried on my desktop, 8 speed burn with Nero. Resolved!

Apache 2.2.4 could not install

Installing popped up a number of errors, least of all that no httpd.conf and other files were missing, and the httpd service had a permission error. I tried a few suggestions online, but nothing worked. The I used the most up to date version, 2.2.11 at the time of writing, and had no issues at all, Windows let everything pass and it worked first time.

ColdFusion 8

Great news – no issues here, worked first time.

In General, it's a pretty good experience, I like the sleeker taskbar and how it hangs together, I am only on day 2 of using it, so that may change.

Calling ANT scripts from ColdFusion

We have been fiddling with getting CF to call a self updating ANT script. There are a few articles around about the undocumented cfant tag.

Getting cfant to run a build file is not all that hard, we loop over the sites in our dev server directory, check to see if a build file exists and try and run the 'updateserver' target.

<cfset buildFile = 'e:\sites\' & SiteName & '\httpdocs\build\build.xml'>
<cfant buildFile="#buildFile#"
defaultDirectory=""
anthome="C:\Program Files\apache-ant-1.7.1\"
messages="output"
target="updateserver"/>

A couple of things to note:

There seems to be a memory leak in here. This runs happily every half an hour for about 3 hours, then jrun decides not to go any more. There is no way we can find to pass in user variables to ANT. i.e. you cant pass in a username / password as you would through the console in Eclipse or via the command line. This is a bit of a down side. We hoped we could have one generic build file and pass the path to it rather than having a build file in each directory.

More on this self updating script shortly.

ANT SVN update project script

We now have a solution to update each of our customer sites on our devserver. We installed ANT on the server to the default directories and then called the undocumented cfant tag via ColdFusion.

Installing the necessary files to get the SVN task working isnt hard, you simply download and drop these files into the /lib directory under ANT home. In our case thats C:\Program Files\apache-ant-1.7.1\lib

svnant.jar svnjavahl.jar svnClientAdapter.jar svnkit.jar ganymed.jar

You can lay your hands on all these files at SVNAnt

[More]

CSS debugging in IE6 and IE7

There are great tools out there for debugging your CSS in Firefox, but IE can be a lot harder to deal with.

This is more of a self note, to remember that there are a few tools out there to help you in IE life.

The developer toolbar for ie6 and ie7 its just about as good as firebug with features like live dom manipulation and an inspector that actually works! Internet Explorer Developer Toolbar

Of course there is a js only distro of Firebug for IE Firebug Lite - we install this into all of our sites to run on development, and used the source file from the developers website directly to ensure we always have the most up to date scripts.

Javascript debugging in Internet Explorer can be aided with the Script Debugger for Windows NT 4.0 and Later

ntext vs nvarchar(max) in SQL 2005

A colleague today told me that using nvarchar(max) in SQL server could be more beneficial than ntext because you can do full text searching and like commands on the field.

Technet has this to say:

"Variable-length Unicode character data. n can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes."

If I read this correctly it means you can only store 4000 characters, however the storage available is massive.

ntext has been deprected, and is therefore not recommended for use in SQL2005. So get this in yer noggin and stop creating new tables with text / ntext to avoid problems later on.

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.