0 Replies Latest reply on Jun 7, 2010 12:46 PM by klmanion

    Retrieving server details in application.cfc when calling CFC from Flex

    klmanion Level 1

      I'm having trouble retrieving processing info inside of application.cfc when calling a CF CFC from Flex.


      I have 2 ColdFusion applications on a CF 7.0.2 server.  These applications both provide the same exact functionality, but one is “Production” and the other is “Training”.  The source code for each is in its own folder under the webroot of the server, one folder is called “MyAppProd” and the other is “MyAppTrain”. 


      Each application maintains its own set of “application” scope variables.  I determine which app is being run by examining the value of CGI.SCRIPT_NAME at the top of the application.cfc file.  If “/MyAppProd/” is found in script_name, then this.name (application scope name) is set to “PROD”.  If “/MyAppTrain/” is found in script_name, then this.name is set to “TRAIN”.  Then my onApplicationStart() function evaluates the value of this.name in order to set the application scope variables to the appropriate values, based on which app is actually being run.  Here’s a shell of the code:




                  <cfif find(“/MyAppProd/”,#cgi.script_name#) NEQ 0>

                              <cfset this.name = “PROD”>

                  <cfelseif find(“/MyAppTrain/”,#cgi.script_name#) NEQ 0>

                              <cfset this.name = “TRAIN”>



                  <cffunction name=”onApplicationStart”>

                              <cfif this.name EQ “PROD”>

                                          <!--- set app scope vars for PROD --->

                              <cfelseif this.name EQ “TRAIN”>

                                          <!--- set app scope vars for TRAIN --->






      This process works great for strictly ColdFusion scripts and it has been in production for a year and half.  However, I recently implemented some Flex 3 charting functionality to the mix and I now have issues identifying which application scope should be used when Flex tries to retrieve its data from the ColdFusion CFC that I’m calling. 


      My problem is simply identifying which app scope to attach the request to.  The CF server ends up trying to execute onApplicationStart() again because the processing falls through the CFIF condition that attempts to identify the app directory.


      I’ve tried checking the value of other CGI variables as well (like PATH_INFO and CF_TEMPLATE_PATH) but none of them seem to have the values that they have when executed directly from a CF script. 


      So my question is…

      How can I retrieve request/script/server processing information when a request is generated from Flex?  I know that requests get processed through the flex2gateway directory, but how does the server know or keep track of which script is getting executed?  Somehow, I need to be able to identify which app directory the script (CFC file) is being executed from.  Any ideas???


      By the way, the Flex chart rendered just fine on my Dev server where there’s only the one default application, so I know there’s no issues with returning the data from CF to Flex.