2 Replies Latest reply on Nov 21, 2008 5:53 PM by wkolcz

    Flex and ColdFusion web services

    wkolcz Level 1
      I have a simple CFC created that encompasses a function that has a query. I want to be able to use the web service in my Flex app, but I am having issues with getting the information from the CFC.

      My function is simple:
      <cffunction name="listBySubject" access="remote" returntype="query" output="false" hint="I grab the newest stories">
      <cfargument name="subject" type="string" required="yes">
      <cfquery name="list" datasource="#myDataSource#">
      SELECT linktext, story, photo
      FROM pressreleases
      WHERE rss_feed = <cfqueryparam value="#arguments.subject#" />
      OR rss_feed2 = <cfqueryparam value="#arguments.subject#" />
      ORDER BY releaseDate DESC
      </cfquery>
      <cfreturn list>
      </cffunction>

      How can I modify that to use in a Flex app's <mx:WebService>? Do I have to use cfsavecontent and return XML or can I keep it a query and use it with an ArrayCollection?

      Something like:
      <cffunction name="listBySubject" access="remote" returntype="xml" output="false" hint="I grab the newest stories">
      <cfargument name="subject" type="string" required="yes">
      <cfquery name="list" datasource="prmc-media">
      SELECT linktext, story, photo
      FROM pressreleases
      WHERE rss_feed = <cfqueryparam value="#arguments.subject#" />
      OR rss_feed2 = <cfqueryparam value="#arguments.subject#" />
      ORDER BY releaseDate DESC
      </cfquery>

      <cfsavecontent variable="storyList">
      <magStories>
      <cfoutput query="list">
      <magStory id="#ISBN#">
      <linkURL>#XMLFormat(linkURL)#</booktitle>
      <story>#XMLFormat(story)#</teaser>
      <photo>#XMLFormat(photo)#</price>
      </magStory>
      </cfoutput>
      </magStories>
      </cfsavecontent>

      <cfreturn storyList>
      </cffunction>

      Locally I can use RemoteObject all day with the way it is normally, but since UofMichigan has BlueDragon, I am forced to convert my apps to WebServices.