that would be what i'm missing. :) Thanks.
-----Original Message----- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Thursday, June 24, 2004 3:25 PM To: [EMAIL PROTECTED] Subject: RE: [CFCDev] CFCs and the Variables scope All web service invocations on CFCs are static, meaning they create a new instance of the CFC, invoke the method, and then throw away the instance. So while setting the customer number in the variables scope will persist for the entire life of the CFC instance, you're not getting the same instnace on subsequent calls. If you want to have this kind of stateful behaviour, you need to use a fa�ade, which is a lightweight wrapper around an instnace of your "real" CFC, which is stored in a persistant scope (like session), for use across multiple requests. Each request to a method of this fa�ade CFC would first instantiate the persistant instance if it doesn't already exist, and then call a method on it, returning the result. Because all the persistant data is in the persistant instance of the "real" CFC, the fa�ade CFC can be stateless, and invoked via web services without issue. Here's how you'd call the web serivce (note the lack of an init() method call): <cfset ws = createObject("webservice", variables.mstrWebServiceURL) /> <cfset ws.setCustomerNumber( 02123456 ) /> <cfset tOrderStuff = ws.createNewOrder() /> And here's a rough sketch of how you're fa�ade CFC would look, with the two methods that are needed above implemented. <cfcomponent display="fa�ade"> <cffunction name="setCustomerNumber"> <cfargument name="num" /> <cfset session.customer = createObject("component", "path.to.CFC") /> <cfset session.customer.init(num) /> </cffunction> <cffunction name="createNewOrder"> <cfif NOT structKeyExists(session, "customer")> <cfthrow type="SomeErrorType" /> </cfif> <cfreturn session.customer.createNewOrder() /> </cffunction> </cfcomponent> Cheers, barneyb > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Nolan Erck > Sent: Thursday, June 24, 2004 3:12 PM > To: [EMAIL PROTECTED] > Subject: [CFCDev] CFCs and the Variables scope > > Done beating my head on the desk. Thought I'd ask for help. > I have a CFC I'm calling like so: > > <cfset ws = CreateObject( "webservice", Variables.strWebServiceURL )> > <cfset ws.init( 012345678 )> <!--- pass in the "customer > number" for the customer we're manipulating ---> > > init() looks like so: > > <cffunction name="init" output="true" access="remote" > returnType="void"> > <cfargument name="customer" type="numeric" required="true"> > <cfset Variables.customer = arguments.customer> > </cffunction> > > which should set Variables.customer as available for the life > of my CFC instance, right? The very next line of code in my > calling template is this: > > <cfset tOrderStuff = ws.createNewOrder()> > > ...and inside createNewOrder() I'm using Variables.customer. > Here's the catch... > > If I move that CFC locally and call it via CreateObject( > "component" ), all is fine. If I move to the other server > and call it via CreateObject( "webservice" ), it says > "customer" is not defined in Variables. It's as if the > object is dying instead of persisting, in between method calls! > > Am I forgetting something about the behavior of CFCs? > > Thanks, > Nolan ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
