Thanks for taking the time to make such a nice example Nathan. This has been pretty confusing to me but explanation has shed enough light on it to make sense to me. It looks like I have some re-work to do. :)
sj > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of Nathan Dintenfass > Sent: Wednesday, May 26, 2004 6:34 PM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] web service persistence? > > It's the nature of a web service -- remember, HTTP is a stateless > protocol, > so just as we have to deal with state in web apps we have to deal with it > in > web services. When you call LoginByEmailAddr() and then Dump() you are > making two separate HTTP requests, each of which is creating a fresh > instance on the server, then destroying that instance (in much the same > way > separate CFINVOKE tags would do). > > For a simple demonstration of this, consider this CFC called > "service.cfc": > > <cfcomponent> > > <cffile action="append" > file="#expandPath("servicelog.txt")#" > output="called #callType()# on #now()# from > #cgi.remote_addr#"> > > <cffunction name="get" access="remote" returnType="string" > output="false"> > <cfreturn "whatever"> > </cffunction> > > <cffunction name="callType"> > <cfif getCurrentTemplatePath() EQ getBaseTemplatePath()> > <cfreturn "remotely"> > </cfif> > <cfreturn "locally"> > </cffunction> > > </cfcomponent> > > > And this calling page: > > <cfobject component="service" name="obj"> > > <cfoutput>#obj.get()#<br />#obj.get()#</cfoutput> > > <cfobject webservice="http://localhost/service.cfc?wsdl" name="obj"> > > <cfoutput>#obj.get()#<br />#obj.get()#</cfoutput> > > If you check the servicelog.txt you'll see one line for the local > instantiation, but two for the remote method calls. > > In general, I'd say it's a best practice to write web service facades for > your business objects, rather than trying to write a single component to > be > used for both -- then your web service facade can do things like state > management that your local "business rule" CFCs shouldn't have to think > about. > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Behalf Of Scott Jibben > > Sent: Wednesday, May 26, 2004 3:38 PM > > To: [EMAIL PROTECTED] > > Subject: [CFCDev] web service persistence? > > > > > > I've created a CFC for users that contains internal properties > > that are set > > when a user logs in. > > > > When I declare an object using the component parameter every > > thing works and > > the internal properties are assigned and useable after the login method > is > > called. > > > > <cfobject component="Users" name="objUsers"> > > <cfset variables.tmp = > > objUsers.LoginByEmailAddr('[EMAIL PROTECTED]', 'test', > > CGI.REMOTE_ADDR)> > > <cfdump var="#objUsers.Dump()#"> > > > > However, when I declare the object using the webservice > > parameter, the login > > either fails or succeeds. However, none of the internal properties > remain > > set and the dump statement will return the default values for the > object. > > > > <cfobject webservice="http://devmx.jibben.com/jws/Users.cfc?wsdl" > > name="objUsers"> > > <cfset variables.tmp = > > objUsers.LoginByEmailAddr('[EMAIL PROTECTED]', 'test', > > CGI.REMOTE_ADDR)> > > <cfdump var="#objUsers.Dump()#"> > > > > I suspect that this has something to do with object persistence. I > would > > like to have the webservice work the same as the component. Are > > webservices > > designed in a way that they do not have a lifespan? > > > > TIA, > > sj > > > > > > ---------------------------------------------------------- > > 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] ---------------------------------------------------------- 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]
