Jorge Loyo said the following on 10/03/2011 08:35 AM:
Would anyone be willing to provide an example of how they handle
returning data as XML from their endpoint? this still has me puzzled. --
<cffunction name="createSession" access="public" returntype="string"
output="false"
hint="Requests an assessment session for a specific assessment
battery."
rest:uri="/session"
rest:method="POST">
<cfargument name="event" type="MachII.framework.Event" required="true" />
<!--- Cod that reads incoming body and creates a return xml packet via
cfsaveconent -->
<!--- Send required response headers --->
<cfset addHttpHeaderByStatus(201) />
<cfset addHttpHeaderByName("Location",
BuildEndpointUrl("retrieveSession", assessmentSession.getSessionId())) />
<cfreturn responseXml />
</cffunction>
I can get it by using http://www.example.com/api/session because my
default format on my REST enpoint is set to XML:
http://trac.mach-ii.com/machii/wiki/IntroToRESTEndpoints#OptionalParameters
Otherwise, you'd have to request it like
http://www.example.com/api/session.xml or
http://www.example.com/api/session.json to get the correct return
format. Or alternately, you can change the auto-discovered format by
doing this in your method if your method changes the return format
programmatically:
<cfset arguments.event.setArg("format", "xml") />
HTH,
.Peter
--
Peter J. Farrell
pe...@mach-ii.com
p...@maestropublishing.com
http://blog.maestropublishing.com
Identi.ca / Twitter: @maestrofjp
--
To post to this group, send email to mach-ii-for-coldfusion@googlegroups.com
For more options and to unsubscribe, visit this group at
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/