2 Replies Latest reply on Jan 29, 2014 8:11 AM by Tomas Sancio

    ReferenceError: Error #1065: Variable [XX] is not defined.


      The flex framework throws the following error when trying to serialize the results of a web service call:


      ReferenceError: Error #1065: Variable Photo is not defined.

      at global/flash.utils::getDefinitionByName()

      at com.adobe.serializers.utility::TypeUtility$/assignProperty()[/Users/sameer/depot/flex/ide _builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/TypeUti lity.as:529]

      at com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[/Users/sameer/depot/fle x/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/Ty peUtility.as:498]

      at com.adobe.serializers.utility::TypeUtility$/convertListToStrongType()[/Users/sameer/depot /flex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utilit y/TypeUtility.as:454]

      at com.adobe.serializers.utility::TypeUtility$/convertResultHandler()[/Users/sameer/depot/fl ex/ide_builder/com.adobe.flexbuilder.dcrad/serializers/src/com/adobe/serializers/utility/T ypeUtility.as:367]

      at mx.rpc.soap::Operation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\4.x\frameworks\projects \rpc\src\mx\rpc\soap\Operation.as:953]

      at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.x\frameworks\projects \rpc\src\mx\rpc\AbstractInvoker.as:313]

      at mx.rpc::Responder/result()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]

      at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncReq uest.as:84]

      at DirectHTTPMessageResponder/completeHandler()[E:\dev\4.x\frameworks\projects\rpc\src\mx\me ssaging\channels\DirectHTTPChannel.as:446]

      at flash.events::EventDispatcher/dispatchEventFunction()

      at flash.events::EventDispatcher/dispatchEvent()

      at flash.net::URLLoader/onComplete()


      This web service call is one of over 100 different calls that I am making in a very large application.  This is the only web service call that has ever had a problem.  The really strange part - I tried to isolate the problem, so I copied the minimum set of files required to execute this call into a new project.  In that project, it works fine and hits my ResultEvent handler as expected.  I've compared all the project settings between the main application and the small test project and they seem to be the same (verified I have all the same .swc files referenced and that the libraries are included the same way - using RSLs).  The only real difference between the test app and the main app is that the main application is broken into many sub modules.  However, even in the module where I'm having this problem I am able to successfully call other web services.  I've searched numerous posts and tried everything I can think of but after several days of researching, I am officially stuck.


      My Environment:

      Flash Builder Version 4.0.1 (build 277662)

      Flex 4.1 SDK

      Web Services:

      Server implementation is Microsoft WCF


      This particular section of the application contains photo album functionality.  The call I'm making is to fetch a list of photos contained in a particular album.  The web service returns an ArrayCollection of objects with type PersonPhotoView (an auto-generated class built by Flex through introspecting the WSDL of the web service).  The signature of the web service call looks like this:


      GetAlbumPhotos(albumID:int, personID:int, targetPage:int):PersonPhotoView[]


      A PersonPhotoView object is defined as having:



      ThePhoto:Photo //From what I understand of the issue and based on the error message, I believe this is the heart of the problem.  The serializer doesn't know what this is.


      ****THE CODE****

      I am using an MVC pattern in my code, so I have my .mxml file that needs the result of the web service call.  It looks like this:


      //**********************MXML FILE*********************

      //invoked when a user clicks on a cover photo of an album. 

      //this code lives inside the item renderer for a photo album object

      private var photoCmd:PhotoCommand = new PhotoCommand();

      private var model:ModelLocator = ModelLocator.getInstance();

      public var photoAlbum:valueObjects.PhotoAlbum;


      protected function albumThumbnailGroup_clickHandler(event:MouseEvent):void


           model.currentAlbum = photoAlbum;

           photoCmd.getAlbumPhotos(onGetPhotosSuccess,onGetPhotosFault, model.currentAlbum);



      //**********************COMMAND CLASS*********************

      The method "getAlbumPhotos" lives inside my command class, and looks like this:

      private var model:ModelLocator = ModelLocator.getInstance();

      private var successCallBackFunc:Function;

      private var faultCallBackFunc:Function;

      private var mediaWS:MediaAPIWebService = new MediaAPIWebService();

      private var params:ArrayCollection = new ArrayCollection();


      public function getAlbumPhotos(successCallback:Function, faultCallback:Function, album:PhotoAlbum):void


           var photo:valueObjects.Photo = new valueObjects.Photo();//dummy reference to compile class...

           var albumView:valueObjects.PersonPhotoView = new valueObjects.PersonPhotoView();//dummy reference to compile class...


           successCallBackFunc = successCallback;

           faultCallBackFunc = faultCallback;




           params.addItem(1);//target page

           mediaWS = new MediaAPIWebService();



           mediaWS.InvokeWebService(handleGetAlbumPhotosSuccess, handleGetAlbumPhotosFault,

                "GetAlbumPhotos", params, true);




                ;//does NOT throw error here





      private function handleGetAlbumPhotosSuccess(event:ResultEvent):void


           for(var i:int = 0; i< event.result.length; i++)


                model.currentAlbumPhotoViews.addItem(event.result[i] as valueObjects.PersonPhotoView);






      private function handleGetAlbumPhotosFault(event:FaultEvent):void





      //***********************WEB SERVICE WRAPPER**************************

      Lastly, I'm using my own web service wrapper class that takes a web service name and invokes that as an abstract operation.  It looks like this:


      public class MediaAPIWebService


           private var model:ModelLocator = ModelLocator.getInstance();

           private var service:services.mediaapi.MediaAPI = new MediaAPI();

           private var resultCallBackFunction:Function = new Function();

           private var faultCallBackFunction:Function = new Function();

           private var app:Object = new Object();

           private var operation:AbstractOperation;



           public function MediaAPIWebService()


                app = FlexGlobals.topLevelApplication;

                operation = new AbstractOperation();




           public function InvokeWebService(resultCallBack:Function, faultCallBack:Function, method:String, params:ArrayCollection, disableApp:Boolean):void


                resultCallBackFunction = resultCallBack;

                faultCallBackFunction = faultCallBack;


                operation = service.serviceControl.getOperation(method);

                operation.addEventListener(ResultEvent.RESULT, onServiceResult);

                operation.addEventListener(FaultEvent.FAULT, onServiceFault);


                if(disableApp == true)


                     app.enabled = false;




                switch (params.length)


                     case 0:



                     case 1:



                     case 2:

                          operation.send(params[0], params[1]);


                     case 3:

                          operation.send(params[0], params[1], params[2]);


                     case 4:

                          operation.send(params[0], params[1], params[2], params[3]);






           private function onServiceResult(event:ResultEvent):void



                app.enabled = true;

                if(resultCallBackFunction != null)





           private function onServiceFault(event:FaultEvent):void



                app.enabled = true;



                if(faultCallBackFunction != null)





      To summarize… I'm using the above described pattern to invoke web service calls all throughout a very large application.  I have implemented over 100 calls using this structure and this is the only call I'm having trouble with.  I copied (literally copied) the same files into a smaller application to isolate the issue and in that application, the web service call is successful.  In fact, even in my main application I inspected the results returned from the service in Network Monitor and the response is there as expected.  For some reason that I cannot determine, the serializer is barfing on "Photo" which is a child object of PersonPhotoView.  In a number of blogs on the subject, people have suggested creating a dummy reference to the class so that the compiler create the linkage at build time.  I have done this (as seen in code above) but it did not work.  I also attempted doing the same in the auto generated class files built against the WSDL.  That did not work either.  If anyone has encountered anything like this before I could really use the help.