Building a webservice in Coldfusion9 and ASP.NET a look at opposing camps
Hi, I'm Eric Fickes <ul><li>Work   :  Lead Technologist  @ </li></ul><ul><li>Twitter   :   @ericfickes </li>...
A tale of two web stacks <ul><li>ADOBE </li></ul><ul><li>  </li></ul><ul><li>FX + { CLOUD }  + </li></ul><ul><li>IIS 7 + C...
K.I.S.S. get's you CRUD webservices <ul><li>CREATE -  Create a new video object in the database   </li></ul><ul><li>  </li...
Starting at the bottom, the database <ul><li>MySQL 5x - one table to power them all! </li></ul>
ORM you glad Adobe didn't say banana?
nHibernate was not as simple
Coldfusion9 Webservice CFC
ASP.NET Webservice ASMX
Let's look at some code and maybe a demo
Coldfusion tips <ul><ul><li>Don't forget to  enable Flash Remoting  ( CFAdmin ) </li></ul></ul><ul><ul><li>Enable Robust E...
ASP.NET tips <ul><ul><li>You can test your webservices in your browser!!!  </li></ul></ul><ul><ul><li>nHibernate IList col...
Thank You <ul><li>If you would like the source code for this demo, or have further questions, grab my card. </li></ul>
Upcoming SlideShare
Loading in …5

Web services Coldfusion9 vs


Published on

My RMAUG ( ) presentation comparing web services done the Adobe way and the Microsoft way. Compared technologies : Coldfusion9 with Hibernate vs ASP.NET with nHibernate. There are some code screenshots along with coding tips for both stacks.

NOTE : Jun Heider and I will giving an in depth comparison of the Adobe and Microsoft stacks at 360|Flex 2010 in San Jose. This talk will be more of an apples to apples since both sides will handle remoting, as well as the latest and greatest ORM and techniques that apply to each side. This preso does not talk about MS Remoting, or MS' Linq to SQL ORM functionality.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • On the internet, end users don&apos;t know what technology is powering their experience, and they don&apos;t care.     What do they care about? Does it work? Is it awesome? The webservices we&apos;re going to be looking at have identical functionality to an end user. This one hour tour is for the coder, the technical decision maker, or just the curious.
  • This is me in a nutshell. I&apos;m the head button pusher, internet brain for Interactive Design &amp; Technology Studio , I have to keep my finger on the pulse, so knowing how to pull off web solutions in differing technologies is key. I tweet mostly when I&apos;m working, so be forwarned that it&apos;s tech related.  If it&apos;s after biz hours, you&apos;ll find out about my son Fletch.   Web, I&apos;m there too.
  • The obvious players to compare are Adobe and Microsoft.   Not the only games in town, but these are the two most common stacks that I work with. These apps were both built on a Windows7 machine running IIS7.  A decision based purely on convenience. On the Adobe side, everything used to build the client and server pieces are out of the box functionality. On the Microsoft side we needed two third party add on. - nHibernate ORM - MySQL&apos;s Connector .net data provider These two libraries where used to keep the stack as similar to the Adobe side as possible. Hibernate was used in this app since it&apos;s built into Coldfusion9, and it made data access ridiculously simple. ASP.NET 3x comes with LINQ ( .NET Language-Integrated Query ) I&apos;m not familiar enough with LINQ to compare it to Hibernate. Since Coldfusion9 has Hibernate bundled with it, using nHibernate would keep the stacks as similar as possible. This isn&apos;t a fair comparison of Adobe&apos;s Remoting vs. Microsoft&apos;s Remoting, but the demo is fast enough. Flash Remoting uses AMF and is fast. .NET&apos;s Remoting uses LINQ and it&apos;s own binary format that is only supported by SL. .NET ASMX services are SOAP, so it&apos;s a bit slower.
  • Update and Delete not shown in SL? Can show Update and Delete in ASMX via browser though
  • simple single table with four columns vid is an auto generated id column the other three columns contain strings same db and table for both stacks same data
  • Coldfusion9 comes with Hibernate built in. You still have to enable it to use it in your application This is everything required to setup Hibernate in this demo app. Application.cfc - turn on ORM, and set your datasource. VIDEO.cfc - This cfc is used as the Hibernate mapping file between coldfusion and the video table in the database.
  • nHibernate is an exact port from Java&apos;s Hibernate, so let&apos;s keep things consistent between the stacks. Not shown here is the NHibernateHelper session factory class.   Every nHibernate operation requires a session.    This singleton class is the recommended way to deal with nHibernate sessions. The setup for nHibernate was not as enjoyable as Hibernate in CF9   Setup : 1.Download and install Connector MySQL .net data provider ( this is what nHibernate uses with MySQL ) 2.Download and install nHibernate   The install process for Connector and nHibernate is primarily adding references in your project to the correct dll files. hibernate.cfg.xml - Next you configure nHibernate to connect to your MySQL DB video.cs - Next you setup your entity class   class notes : - use getter setters - mark properties as public virtual   video.hbm.xml - Next you setup your mapping file tie-ing your entity class to your table in the DB.
  • Flash Remoting is also enabled in the CF Admin under Flex Integration. If you don&apos;t enable Flash Remoting, Flex clients won&apos;t be able to call remote CFC functions ( the webservices )   webservices in Coldfusion are built in CFCs the CFC cffunction&apos;s have their access set to remote   using ORM cut&apos;s down on amount of code to be written   if you&apos;re not totally happy with ORM, don&apos;t go 100% ORM, mix it up.   
  • This demo uses standard .net WebServices ASMX .NET has it&apos;s own flavor of remoting called WCF Webservices. WCF Webservices are only supported by Silverlight right now. ASMX Webservices can be consumed by anybody The nHibernate code is more like Java&apos;s Hibernate than CF9&apos;s easy Hibernate. nHibernate still cuts down the amount of code needing to be written, but it&apos;s not as simple as CF9&apos;s
  • No Flash Remoting, no dice! When you run into CF errors, the server will suggest you turn this on.  Might as well turn it on while you&apos;re setting up your server. While I&apos;m figuring out code, I like to build my function as a standalone block in a test.cfm page. Once complete, refactor that block of code into my cfc cffunction. By setting the cffunction&apos;s output to true, you can call this cfc.cffunction in test.cfm and have it spit the results out to the page. This saves time on the server before going all the way to your Flex client to test data services. While it&apos;s not terribly helpful, you can view your webservice.cfc in a browser.  The CF server will render it out in a classdoc format. While a sniffer might not help decoding AMF traffic, you must have a good sniifer.
  • My favorite part of building webservices in .net is the ability to test them in your browser. Loading your webservice.asmx file in a browser first shows you the breakdown of the webservice - each method is a clickable link - clicking a method shows you how to use it via SOAP 1.1, SOAP 1.2, and HTML POST - the method screen also builds a form so you can invoke this webmethod - if the webmethod doesn&apos;t receive any input, an &amp;quot;Invoke&amp;quot; button will appear nHibernate&apos;s IList doesn&apos;t support the IList&lt;genericType&gt; feature, and .net has a hard time serializing when returning from a webservice. If you need to return a collection of custom class objects and you&apos;re using nHibernate, after retrieving your nHibernate IList, copy the items into a .net List&lt;genericType&gt; and return that List instead.  ASMX has no problem with this route. Just like when you&apos;re working with FlashRemoting, Silverlight also requires access XML files. clientaccess.xml goes in the root of your Silverlight application and crossdomain.xml goes in your webserver&apos;s root folder. * these config files are tricky, I had to copy both files to both locations to get things working, but didn&apos;t bother figuring out the minimum requirements Do us all a favor and don&apos;t even bother with VB.NET. Can&apos;t stress enough how important it is to have a network sniffer when you&apos;re developing webservices, or really any RIAs that talk to a remote server.
  • Web services Coldfusion9 vs

    1. 1. Building a webservice in Coldfusion9 and ASP.NET a look at opposing camps
    2. 2. Hi, I'm Eric Fickes <ul><li>Work : Lead Technologist @ </li></ul><ul><li>Twitter : @ericfickes </li></ul><ul><li>Web : </li></ul>
    3. 3. A tale of two web stacks <ul><li>ADOBE </li></ul><ul><li>  </li></ul><ul><li>FX + { CLOUD } + </li></ul><ul><li>IIS 7 + Coldfusion9 + Hibernate + MySQL </li></ul><ul><li>MICROSOFT </li></ul><ul><li>SL + { CLOUD } + </li></ul><ul><li>IIS 7 </li></ul><ul><li>+ ASP.NET </li></ul><ul><li>+ nHibernate + MySQL </li></ul>
    4. 4. K.I.S.S. get's you CRUD webservices <ul><li>CREATE - Create a new video object in the database </li></ul><ul><li>  </li></ul><ul><li>READ - Return a collection of custom class Video to the client </li></ul><ul><li>  </li></ul><ul><li>UPDATE - Update video record </li></ul><ul><li>DELETE – Remove video record </li></ul>
    5. 5. Starting at the bottom, the database <ul><li>MySQL 5x - one table to power them all! </li></ul>
    6. 6. ORM you glad Adobe didn't say banana?
    7. 7. nHibernate was not as simple
    8. 8. Coldfusion9 Webservice CFC
    9. 9. ASP.NET Webservice ASMX
    10. 10. Let's look at some code and maybe a demo
    11. 11. Coldfusion tips <ul><ul><li>Don't forget to enable Flash Remoting ( CFAdmin ) </li></ul></ul><ul><ul><li>Enable Robust Exception Information ( CFAdmin ) </li></ul></ul><ul><ul><li>Build your code in a standalone test.cfm file </li></ul></ul><ul><ul><li>Refactor code into your CFC and enable output </li></ul></ul><ul><ul><li>You can test code in test.cfm </li></ul></ul><ul><ul><li>Then final testing in your Flex client </li></ul></ul><ul><ul><li>CFDUMP is your friend </li></ul></ul><ul><ul><li>Loading your webservice.cfc shows you classdocs </li></ul></ul><ul><ul><li>Install TamperData Firefox Addon </li></ul></ul>
    12. 12. ASP.NET tips <ul><ul><li>You can test your webservices in your browser!!! </li></ul></ul><ul><ul><li>nHibernate IList collections need to be wrapped  </li></ul></ul><ul><ul><li>Silverlight needs clientaccess.xml and crossdomain.xml files for webservices just like flash does. </li></ul></ul><ul><ul><li>If you want Remoting, but not .NET remoting, use WebORB </li></ul></ul><ul><ul><li>C# is awesome </li></ul></ul><ul><ul><li>Install TamperData Firefox Addon </li></ul></ul>
    13. 13. Thank You <ul><li>If you would like the source code for this demo, or have further questions, grab my card. </li></ul>