0 Replies Latest reply on May 9, 2006 4:31 AM by dtotal

    CFC return type XML

    dtotal Level 1
      Hi there,

      I'm using a remote CFC (gateway.cfc) as an interface to another public CFC (service.cfc). Service.cfc does a database search and returns RSS formatted XML to gateway.cfc. A stripped down version of the code is below:

      gateway.cfc
      =========
      <cfcomponent>
      <cffunction name="search" access="remote" returntype="xml">
      <cfargument name="something" type="string" required="yes" />

      <cfinvoke component="service" method="webSearch" argumentcollection="#arguments#" returnvariable="rss" />
      <cfreturn rss />

      </cffunction>
      </cfcomponent>

      service.cfc
      ===========
      <cfcomponent>
      <cffunction name="webSearch" access="public" returntype="xml">
      <cfargument name="something" type="string" required="no">

      <cfxml variable="rss">
      <rss version="2.0">
      <channel>
      <title>Title</title>
      <description>Description</description>
      <link> http://www.somedomain.com</link>
      <pubDate>#DateFormat(Now(),"ddd, dd mm yyyy")#</pubDate>
      <item>
      <title>Item Title</title>
      <link> http://www.somewhere.co.uk/</link>
      </item>
      </channel>
      </rss>
      </cfxml>

      <!--- <cfdump var="#rss#" />
      <cfabort />--->

      <cfreturn rss />

      </cffunction>
      </cfcomponent>



      I invoke the web service using:
      gateway.cfc?method=search&something=stuff

      The error returned is: "The value returned from function webSearch() is not of type xml". But, if you un-comment the CFDUMP and CFABORT, and run it again, it dumps out a properly formatted XML document.

      If you set service.webSearch as returntype="any" and gateway.search as returntype="string", it outputs this:
      coldfusion.xml.XmlNodeList@ed8b42

      Which appears to be a pointer or something!?

      So... does anyone know if it's possible return XML in this way? Or have I missed something obvious? (as usual)