Thank you so much for the example, and works perfectly. I was also able to load raster layer using the DynamicLayer class, is that an effective way of loading the service, since dynamicLayer is no cached?
Any ways both ArcGISDynamicMapServiceLayer and Dynamic layer works for raster layer. Which one do you think is more efficient?