Publishing Web Services with ColdFusion

My last blog dealt with consuming web services with ColdFusion.  In this entry I will discuss how to publish a web service using ColdFusion.  To reiterate, my knowledge going into this subject was limited, but once again ColdFusion has made a complex topic quite easy to grasp.  In fact, I had actually been using the web service publishing capabilites of ColdFusion for a little while without even realizing it.  Let me show you just how easy it is. 
 
To create / publish a web service, you must start by defining a component, and like any component it may have one or more functions.  Let’s look at this simple Hello World example:
 
     <cfcomponent>
 
          <cffunction name="init" returntype="string">
               <cfreturn "Hello World">
          </cffunction>    
 
     </cfcomponent>
 
So we have a simple component that defines one function name init that returns the string "Hello World".  To turn this into a web service, consumable by any language that supports it, is add ONE attribute to the function:
 
     <cfcomponent>
 
          <cffunction name="init" returntype="string" access="remote">
               <cfreturn "Hello World">
          </cffunction>    
 
     </cfcomponent>
 
All I have done here is added the access attribute to the function and specified its value as remote.  That’s it!  We now have a fully function web service with a method that will return a string.  Assuming this component is named myFirstWebService and it lives directly on your web root, you can call it directly like the following:
 
 
Doing so will produce an html output page featuring descriptions of the web service and its functions from the self documenting features of ColdFusion components.
Add ?WSDL to the end of the URL and you will see the WSDL definition of the service, which is the URL that can be used to consume your brand new service.  And that is it!
 
I hope this brief introduction can help you get started in publishing your own services.  Next time I will discuss object creation in ColdFusion and how to use Objects in Web Services, as well as modeling complex types with structs in ColdFusion.
 
Happy Coding!
 
Posted in ColdFusion | Leave a comment

Consuming Web Services with ColdFusion

The agency I work for is implementing the Avatar clinical software system from Netsmart Technologies.  Netsmart has recently released a collection of Web Services for the Avatar system to extend it’s functionality.   It became my duty to fully leverage these Web Services using my favorite language, ColdFusion.  Up until this point I have never worked with a Web Service or even fully understood what one is.  So, I put on my learnin’ hat and started searching around the web for some information.  I soon learned that a web service, loosely and briefly designed can be summized as a way for two software systems, written in different languages and running on different platforms, to talk to each other using a standardized language they can both understand over a protocol they can both understand.  The language in this case is XML (extensible markup language) and the protocol is HTTP (hypertext transfer protocol).  Okay, so now that I know what it is, how can I use it?  A little bit more research and I found out that ColdFusion makes using a Web Service, which is formally referred to as "Consuming" the service, extremely simple.  In fact, ColdFusion has two equally simple ways to consume: using the <cfinvoke> tag or the createObject() function with the "webservice" argument. 
 
The tag based solution works like the following:
 
   <cfinovke webservice="urlToTheWSDL" method="nameOfMethod>
        <cfinvokeargument name="argumentName" type="argumentType">
                                                .
                                                .
                                                .
    </cfinvoke>
 
For the webservice attribute, all you need to do is specify the URL to the WSDL file of the web service.  Every web service you will consume has an accompanying WSDL (Web Service Defintion Language) file that describes what the web service does, what its methods / functions are , and what data types it takes in and returns.  To call a specfic function of the web service, just supply its name in the method attribute.  If the method takes in arguments, you can specify those using <cfinvokeargument> tags, supplying the name of the argument as well as the type.  The type can be simple (string, numeric, boolean,…) or complex (struct, array, user defined object, array of object, …).  If the web service returns a value, you can use the returnvariable attribute of the <cfinvoke> tag to capture it for further processing. 
 
The function based solution looks like this:
 
     <cfset ws = createObject("webservice", "urlToTheWSDL")>
     <cfset returnValue =  ws.nameOfMethod(arg1Name = arg1Value, arg2Name = arg2Value, …)>
 
  or using scripting…
 
     <cfscript>
          ws = createObject("webservice", "urlToTheWSDL");
          returnValue = ws.nameOfMethod(arg1Name = arg1Value, arg2Name = arg2Value, …);
     </cfscript>
         
All you do here is create a web service object, then call methods of the object passing name / value pairs to it.  While this second method requires two seprate steps to consume the service, I prefer it as I believe it has a cleaner appearance when there are multiple arguments to send to the method. 
 
As I hope you can see, ColdFusion makes working with the basic functionality of Web Services quite painless.  In later posts, I will examine how to create, or publish, a Web Service using ColdFusion, as well as dealing with complex data types that are often used in Web Services.
 
Hope this information is useful.  Happy Coding!
Posted in ColdFusion | Leave a comment

Mom: In Memorium

November 14th, 2009 marked the 3 year anniversay of my Mother’s sudden and untimely passing.  While my Mother was sick, nothing of Her condition was terminal and She was taken from us much too soon, having only spent 52 short years on this plane.  This is the first time in these three years that I have felt comfortable, nay even found it necessary to write about this most sad event. 
 
The loss of my Mother was for me the most singularly painful and sorrowful event of my then 28 years on the planet.  3 years later and the pain remains almost as fresh.  I am told by those that have suffered through similar losses that these monumental feelings will last a lifetime, dulling little with the passing years.  The thought of enduring this lasting pain does not discomfort me as it allows me to recognize the enormous love I have for my Mother, such that not having Her with me in this life can cause such pain.
 
It is always my plan to remain busy this time of the year, keeping my mind occupied with important work and trivial daily tasks as a buffer to the emotions that are so difficult to deal with.  This is my defense; I know none other.  I really should talk to others more about this, and perhaps this marks my entry into this new endeavour.  I find it interesting that my family does not directly discuss this event.  We remember fondly good times and memories of Mom throughout the year but no specifics about Her passing.  I guess my family is only as ready as I am to communicate this event, which is completely acceptable and totally understandable.  As for me, I want to say how much I love my Mother, how tragically I mourn Her passing, and how I will think of Her everyday of my life. 
 
I love you, Mom.
 
Posted in Life | 2 Comments

Gathering Multiple Dataset Information in a Single Query

I’ve come across situations before and again this morning where I had to compile information in one report from multiple datasets.   Usually this is no problem, however this morning I found myself needing to use the results from one dataset to filter out results from a separate dataset.  My first data set grabbed a distinct list of codes from an access database on a network share and I needed to feed that list as a filter to a second query to a SQL Server table.  My solution was to store that data from the Access query in a report parameter that I could then feed into the second query.  To do this I created a report parameter, set its internal attribute to true (checked), and defaulted its values to that of the query from the Access database.  In my second query I then used the report parameter name in the IN statement of the WHERE clause to provide the filtering, as such:
 
SELECT <column_name>
FROM <table_name>
WHERE <column_name_to_filter> IN (@ReportParameter)
 
This solution works beautifully, but is limited to simple result sets.  I’m still interested in finding solutions to handle more complex data from multiple sources. 
 
Hope this helps.  Happy Reporting!
Posted in Uncategorized | Leave a comment

Talking about Installing 32-bit ODBC Drivers on Windows 7

 I had to create a report today that used information from two different data sources, the first was SQL Server, and the second was an Access database.  I needed to create an ODBC connection to the Access database first so that I could query the data in my report.  I am running Windows 7 64 bit, and from prevous experience I know that I should be creating a 32 bit ODBC connection and that Windows provides both a 64 bit and 32 bit ODBC manager.  I opened up my System32 folder and found the 32 bit ODBC executable, odbcad32.exe and launched it.  Much to my suprise, there was no Access driver listed in the manager.  I did some quick searching and came across this incredibly helpful article.  The article explains that the odbcad32.exe that exists in the System32 folder is in actuality the 64 bit ODBC manager, and that both the 32 bit and 64 bit ODBC managers exist in the 64 bit system directory, SysWOW64, with the 32 bit manager having the same name (odbcad32.exe) as the 64 bit in the 32 bit directory (is that enough bits yet?).  Once I found the proper manager, I was able to add my DSN and get the report running. 

On a side note: this issue came about after having solved another cool problem, which was using data from one dataset into another.  I’ll create another entry to describe that process and solution.

Hope this helps.  Happy Reporting!

Posted in SSRS | 2 Comments

Disney’s Partners in Excellence Award

On Tuesday, May 26th, I was honored to accompany my sister, Mari, as her guest to Disney’s Partners In Excellence Award Dinner.  Mari works as an electrician at Disney’s Hollywood Studios and is responsible for repairing many of the animatronics in use at the Muppet Show and the brand new Toy Story attraction.  Through hard work and dedication to her role, she was nominated and ultimately given the Partners In Excellence Award, which is the highest award a cast memer at Disney can achieve.  Disney hosted an awards banquet at the Contemporary hotel to honor all of the recipients of the award.  I was completely blown away by the extent to which Disney went to show their appreciation to the winners.  It was a semi-formal affair and everyone was in their Sunday best.  We were first given the opportunity to have a professional picture taken with a faux copy of the award trophy.  After that we attended a beautiful reception with an open bar and several kinds of scrumptuous appetizers.  We were later led downstairs for the official dinner.  Seating was pre-determined and at each recipient’s seat was their own incredible trophy.  The award was a bronze image of Walt Disney holding the hand of Mickey the Mouse, on a marble platform attached to a wooden base.  The whole thing was approximately 12 inches tall and weighed 10 pounds.  The dinner featured several performances by cast members singing various Disney songs, accompanied by dancing costumed characters.  There was an early buzz about a guest speaker, and it turned out to be John Quinones of abc news fame.  John spoke about heroes in America, and like most of these speeches it was a publicity attempt to sell copies of his book,  but nevertheless he came across with some encouraging words and uplifting stories that helped add an even more positive note to the evening.  The dinner wrapped up with more song and dance followed by indoor fireworks that took me completely by suprise.  I qik’ed a few videos during the evening which you can see here and here.  What I really want to say is just how proud I am of my sister for receiving this award.  She works very hard and is well deserving.  Congratulations, Mari!
Posted in Life | Leave a comment

FlashCamp Orlando

I had the great opportunity yesterday to attend FlashCamp Orlando and wanted to share my thoughts about the event.  For those that know me, I have been strictly a ColdFusion developer for the last year and a half.  I’ve heard a lot of talk recently about Flex and Air and I was very curious to see how and if these technologies could enhance or help my current development strategies.  I heard about this event through a contact on Twitter, which is one of the main reasons I have a twitter account.  I quickly got authorization from my boss to attend (thanks Lenny!) and registered.  My expectations of the event were solely to get a basic understanding of the Flex framework to once again see how I might integrate it into my current development environment.  The event featured guest speaker Greg Wilson of Adobe evangelism fame, whom presented on Tour de Flex, which features great examples on what is possible with Flex development.  Among those examples was a heatmap demonstration.  The heatmap plots points in real time of users around the world as they access the Tour de Flex app.  In fact, right before our eyes we saw hits on the map for Orlando, Florida as Greg accessed the app.  We were also informed of an upcoming contest scheduled to begin next Monday or Tuesday (June 1st or 2nd), where the data stream for the heatmap will be made available with the goal to execute the best use of the data via a Flex app.  Next we heard from Jason Madsen with a session on making the jump to Flex.  This was my favorite presentation as it was aimed at beginners to Flex.  Jason gave a great introduction to the framework and how easy it can be to begin Flex development.  We also heard from various members of the Universal Mind team, whom helped organize the event.  Among these included David Tucker on "Working with Data in Air, Christian Saylor on "The Art of Storytelling", and Andy Powell on "Implementing BlazeDS".  All of these gentleman are extremely talented, and in fact most of their material went straight over my head as I am but a beginner to this platform.  Nonetheless, the information provided was exciting and inspiring.  It’s developers like these that encourage me to continue working towards my goals at becoming the best devloper I can be.  Probably the coolest part of the event was the end when the giveaways took place.  We had approximately 80 attendees and their were four prizes to give away.  I was fortunate enough to have my name called for the giveaway of an ILOG Elixir software package.  I will definitely begin Flex devlopment now, as I am already thinking of the some of the incredile things I will be able to achieve. 
 
To sum up, I had a fantastic time at this event and am very glad to have it come to Orlando.  I will be looking forward to future events.  And if you are a devloper of Adobe technologies, I encourage you to check out your local user group.  Here in Orlando we are proud to have the Adobe Developers of Greater Orlando.  Check ‘em out today!
 
Happy Camping!
Posted in Flex | Leave a comment