.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 Smartermail Web Services and API to create domains with ColdFusion

We have moved our email services in house over to SmarterMail because of its history, power and flexibility. We used to use MailEnable, and although we like supporting Aussie companies, Smartermail is just that bit more mature.

Now to make it easy on clients and ourselves, we have minimised the amount of knowledge required to set up new domains, and by adding this code into out intranet, its now simply a case of clicking a button to have the clients domain added, and have the details available ready to hand out. Then we simply hook up the DNS and MX records and we are off!

[More]

Discount Images on Amazon ECS images

This is a nice feature to help people visualise the savings they can be making on a product.

Add a save 20% off icon to your images.

[More]

Using Your Associates ID with Amazon ECS

The URL's that Amazon returns for you through ECS can be altered to include your Amazon associates tag in the URL without you having to butcher and manually alter the URL.

How? Simply add it to the request URL you use.

<cfset ASIN = ""><!--- The asin code you just picked --->
<cfset accesskey = ""><!--- Your unique API access key --->
<cfset ASIN = "sixfive-21"><!--- Your associates ID --->
<cfset var AmazonURL = "http://ecs.amazonaws.co.uk/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=#accesskey#&AssociateTag=#associateTag#&Operation=ItemLookup&MerchantID=All&ItemId=#ASIN#&ResponseGroup=Medium">

Now all links and URL's will be nicely formatted for you.

Why do these things if it can be done for you?

Using the Amazon Ecommerce Services in ColdFusion

I have had a long a flirting relationship with Amazon ECS thru using it with PHP and SOAP, and now that I am totally ColdFusion reliant I have revisited the products section on my site, and done something a bit more useful with it.

Amazon ECS is a pretty simple system.

  1. Hit a URL with some variables
  2. receive XML response
  3. process XML to something friendly
  4. display or save that info

So how is it done?

[More]

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