4 Replies Latest reply on Oct 5, 2007 11:29 AM by ab1301

    httpServices in Modules

    ab1301 Level 1
      Has anyone gotten httpServices to work inside of a module? Is there any documentation on how to do this, or any examples online of modules with httpServices? All of the module examples I have seen so far have fake data written into the mxml.

      I was really excited about modules, but they are useless if you can't get any data, and so far I cannot get even the simplest httpService to work in a module. The attached code is a simple module with a simple httpService. The code works fine when it is put into an application, but when I compile it as a module, and try to load the module, I get the following error:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.rpc::AbstractInvoker$cinit()
      at [newclass]
      at global$init()[E:\dev\flex_3_beta1\sdk\frameworks\projects\rpc\src;mx\rpc;AbstractInvoker. as:48]
      at global$init()[E:\dev\flex_3_beta1\sdk\frameworks\projects\rpc\src;mx\rpc\http\mxml;HTTPSe rvice.as:88]
      at photoMod/photoMod::_photoMod_HTTPService1_i()[C:\Documents and Settings\Doug\My Documents\Flex Builder Moxie\Duke of Clubs;;photoMod.mxml:3]
      at photoMod()[C:\Documents and Settings\Doug\My Documents\Flex Builder Moxie\Duke of Clubs;;photoMod.mxml:3]
      at _photoMod_mx_core_FlexModuleFactory/create()
      at mx.modules::ModuleLoader/private::moduleReadyHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at private::ModuleInfoProxy/private::moduleEventHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at private::ModuleInfo/readyHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::FlexModuleFactory/mx.core:FlexModuleFactory::update()[E:\dev\flex_3_beta1\sdk\fr ameworks\projects\framework\src;mx\core;FlexModuleFactory.as:317]
      at mx.core::FlexModuleFactory/mx.core:FlexModuleFactory::docFrameHandler()[E:\dev\flex_3_bet a1\sdk\frameworks\projects\framework\src;mx\core;FlexModuleFactory.as:382]
      at [execute-queued]
        • 1. Re: httpServices in Modules
          Gaurav J Adobe Employee
          httpService works fine from Modules. Can you also send the code in which you load the module.

          Thanks,
          Gaurav
          • 2. Re: httpServices in Modules
            ab1301 Level 1
            I'll send it when I get home. Basically, the only real difference I can see from how you were trying to replicate it was that I set the url directly in the module tag like this: <mx:ModuleLoader url="clubmod.swf">.

            I'm not the only one who had this problem. There was another guy on flexcoders who ran across this here: http://tech.groups.yahoo.com/group/flexcoders/message/86823. Someone told him to try putting a dummy httpService in the main application, and that if that worked, it meant it was a "shared code" problem, or a "class collision" whatever that means.

            Anyway, I tried putting a dummy httpService in the main app, and it worked. So now I have a work around, but I can't understand why it worked or why I had the problem in the first place.
            • 3. Re: httpServices in Modules
              Gaurav J Adobe Employee
              Class collision problem occurs when you are trying to load two modules and bot of them using httpservice. In such cases their definitions don't match.

              By adding it to the main app, the definition which gets loaded as part of the main app domain is used for both modules, so they work fine.

              Hope it makes it somewhat clear.
              • 4. Re: httpServices in Modules
                ab1301 Level 1
                I initially encountered the problem when trying to load a single module into an application. There were no other modules, but there were three httpServices in the module. When I couldn't get that to work, I created a new project with a stripped down application and module, with only one httpService. It still didn't work until I added the dummy httpService to the application.

                Whatever the problem is, this should be added to the documentation, because I'm sure that lots of people using modules are likely to load more than one module with an httpService.