Ok, that explains a few things. The CategoryServices.cfc is a facade for
the category.cfc (which is a catagory object). Man, this stuff is too
confusing. I wonder if I'm even on the right track now. I have a
subcategory complex datatype object which has complex datatypes within
it's own properties. I just read a technote that said I wouldn't be able
to use CF webservices for Flash connection with these types of objects
(although it wouldn't have a problem with .Net webservices? I hope that
technote was out of date...), that I would have to use Flash Remoting.

My biggest problem is finding a solid example of this kind/type of CF
programming. I am writing a custom e-comm application. Currently I have
several custom objects written (size, color, design, category,
subcategory, subsubcategory, itementity, apparelitem, shirtitem,
appcolor, appsize). Several of these objects are extensions of their
super object types. Most have been tested, but new requirement has been
the need for a Flash (MX 2004 Pro) front end (oh fun...) Moving to a
(somewhat) OO architecture has been interesting enough (though a
terrific time saver in the end run), but this is placing some whole new
twists in the equation (with a quickly shortening deadline). If I can
just get around the first object I think I can get this. Any and all
help is greatly appreciated, and I will gladly share some solutions when
I come to them.

Cutter

Nathan Dintenfass wrote:

> I'm jumping into this thread late (been out of town for 5 weeks), so
> hopefully I'm not repeating stuff you've already heard.
>
> The issue is that the web service client (in your example, CF itself) is not
> holding onto the session identifiers (either CFID/CFTOKEN or JSESSIONID,
> depending on whether you are using J2EE sessions on your CF server).  Each
> request would need to contain that information for session variables to
> work.
>
> What's worse, it's not that the CF server is not keeping the session
> variables, it's that CF is actually creating a NEW session every time you
> call a method via web services (in the way you have it set up).
>
> You could make part of your API a session identifier that needs to be passed
> with each request, where you would have your clients call some kind of
> "getSession" method, then use the identifier as one of the arguments each
> time -- you would have to semi-manually set the session identifiers for the
> request then.
>
> More generally, statefulness and web services don't often mix well.  If you
> do go down that road, it's usually recommended that you create a separate
> "facade" that handles the web service interface and session stuff and calls
> back into a separate component that deals with the actual logic -- that
> creates cleaner encapsulation and makes the "logic" code much more reusable
> in other contexts.
>
>
>
>
>
>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>Behalf Of Cutter (CF-Talk)
>>Sent: Tuesday, August 03, 2004 11:04 AM
>>To: [EMAIL PROTECTED]
>>Subject: Re: [CFCDev] CFC webservice issues - round two
>>
>>
>>Thanks to all who have been assisting here. After reading all of the
>>various replies, as well as a lot of time reading over two tons of
>>articles, I appear to be (slowly) making some progress.
>>
>>Currently I am using a CategoryServices.cfc to access the category
>>object created by my category.cfc. I am able to initialize the object
>>using the following init() method:
>>
>> <cffunction name="getCategory" access="remote" returnType="struct"
>>output="false">
>> <cfargument name="ID" type="numeric">
>>
>> <cfscript>
>> variables.returnStruct = StructNew();
>> variables.returnStruct.ID = 0;
>> variables.returnStruct.catName = "";
>> variables.returnStruct.status = 1;
>>
>> if (arguments.ID neq 0)
>> session.newCat =
>>CreateObject('component','category5').init(arguments.ID);
>> else
>> session.newCat =
>>CreateObject('component','category5').init();
>>
>> variables.returnStruct.ID = session.newCat.getID();
>> variables.returnStruct.catName =
>>session.newCat.getCategoryName();
>> variables.returnStruct.status =
>>session.newCat.getStatus();
>> </cfscript>
>>
>> <cfreturn variables.returnStruct>
>> </cffunction>
>>
>>I thought that be instantiating the object within a session variable
>>that it would perpetuate for further method calls along these lines:
>>
>><cffunction name="deleteCat" access="remote" returntype="void"
>>output="false">
>> <cfargument name="ID" type="numeric">
>>
>> <cfif arguments.ID neq 0>
>> <cfset session.newCat.delete(arguments.ID)>
>> </cfif>
>> </cffunction>
>>
>> <cffunction name="setCatName" access="remote" returntype="void"
>>output="false">
>> <cfargument name="catName" type="string">
>> <cfset
>>session.newCat.setCategoryName("#arguments.catName#")>
>> </cffunction>
>>
>> <cffunction name="setCatStatus" access="remote" returntype="void"
>>output="false">
>> <cfargument name="status" type="boolean">
>> <cfset session.newCat.setStatus(arguments.status)>
>> </cffunction>
>>
>> <cffunction name="createCat" access="remote" returntype="numeric"
>>output="false">
>> <cfscript>
>> session.newCat.create();
>> returnID = session.newCat.getID();
>> </cfscript>
>> <cfreturn returnID>
>> </cffunction>
>>
>>But what I find is, though I can initialize through the webservice:
>>
>><cfinvoke
>>  webservice="http://[mypath]/boutique/CategoryServices.cfc?wsdl"
>>  method="init"
>>  returnvariable="aCat">
>> <cfinvokeargument name="ID" value="1">
>></cfinvoke>
>>
>>
>><cfdump expand="yes" var="#aCat#"><br />
>>
>>The session variable apparently does not persist. The next line of code:
>>
>><cfdump expand="yes" var="#session.newCat#">
>>
>>gives the following error:
>>
>>Error Occurred While Processing Request
>>Element NEWCAT is undefined in SESSION.
>>
>>
>>The error occurred in [mypath]\testing.cfm: line 18
>>
>>16 :
>>17 : <cfdump expand="yes" var="#aCat#"><br />
>>18 : <cfdump expand="yes" var="#session.newCat#">
>>
>>
>>  Is the session variable created here not persistent? Is it
>>automatically "cleaned" once a method has been completed?
>>
>>Cutter
>>
>>
>>Barney Boisvert wrote:
>>
>>
>>>Here's some sample code.  I think it'll illustrate better than textual
>>>explanation.  It's greatly abbreviated, but all the critical pieces
>>>are there.  Note that this is totally untested code, and could well
>>>not even compile, since I typed it directly into the webmail form
>>>field.
>>>
>>>user.cfc (more or less what you've got right now)
>>><cfcomponent displayname="user">
>>>  <cffunction name="init" access="public" output="false"
>>
>>returntype="void">
>>
>>>    <cfargument name="dsn" type="string" required="true" />
>>>    <cfset variables.dsn = dsn />
>>>    <cfset variables.my.name = "" />
>>>    <cfreturn this />
>>>  </cffunction>
>>>  <cffunction name="setName" access="public" output="false"
>>
>>returntype="void">
>>
>>>    <cfargument name="name" type="string" required="true" />
>>>    <cfset variables.my.name = name />
>>>  </cffunction>
>>>  <cffunction name="create" access="public" output="false"
>>
>>returntype="void">
>>
>>>    <cfset var getID = "" />
>>>    <cfquery datasource="#variables.dsn#">
>>>      INSERT INTO user
>>>        (name)
>>>      VALUES
>>>        (<cfqueryparam cfsqltype="cf_sql_varchar"
>>
>>value="#variables.my.name#" />
>>
>>>        )
>>>    </cfquery>
>>>    <!--- there are usually much better ways to do this --->
>>>    <cfquery datasource="#variables.dsn#" name="getID">
>>>      SELECT MAX(userID) AS newUserID
>>>      FROM user
>>>    </cfquery>
>>>    <cfreturn getID.newUserID />
>>>  </cffunction>
>>></cfcomponent>
>>>
>>>facade.cfc
>>><cfcomponent displayname="facade">
>>>  <cffunction name="init" access="remote" output="false"
>>
>>returntype="void">
>>
>>>    <cfset session.activeUser = createObject("component",
>>>"user").init(application.config.dsn) />
>>>  </cffunction>
>>>  <cffunction name="setName" access="remote" output="false"
>>
>>returntype="void">
>>
>>>    <cfargument name="name" type="string" required="true" />
>>>    <cfset session.activeUser.setName(name) />
>>>  </cffunction>
>>>  <cffunction name="create" access="remote" output="false"
>>
>>returntype="numeric">
>>
>>>    <cfreturn session.activeUser.create() />
>>>  </cffunction>
>>></cfcomponent>
>>>
>>>Hope that helps shed some light on the matter, and keep asking
>>
>>questions.
>>
>>>cheers,
>>>barneyb
>>>
>>>On Sat, 31 Jul 2004 11:06:38 -0400, Cutter (CF-Talk)
>>><[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>>OK, so (if I'm picking this up correctly) I can set up a CFC for my
>>>>object (category) with some properties defined through cfproperty:
>>>>
>>>>ID
>>>>catName
>>>>status
>>>>
>>>>Then I can set up my basic 'public' or 'private' methods (does CF still
>>>>create the get/set methods of the properties automatically, even though
>>>>this CFC isn't a webservice?):
>>>>
>>>>init([ID])
>>>>get(ID)
>>>>update(ID,[catName],[status])
>>>>create([catName],[status]) [or maybe new([catName],[status])]
>>>>delete(ID)
>>>>list()
>>>>
>>>>And then my webservice is basically a CFC for accessing my object:
>>>>
>>>>getCategoryService(ID) returns type category
>>>>setCategoryService(ID,catName,status[???]) calls category.create()
>>>>updateCategoryService(ID,catName,status[???]) calls category.update()
>>>>
>>>>Am I, somewhat, on the right track here? I can't use Flash Remoting
>>>>because my host may not have it enabled (and even if they do it will be
>>>>harder to get them to get it working correctly than it would be to
>>>>design it using webservices, and I can't (currently) switch hosts).
>>>>
>>>>Thanks again for everyone's assistance.
>>>>
>>>>Cutter
>>>
>>>----------------------------------------------------------
>>>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]
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to