getting remote proxies to return xml

0 views
Skip to first unread message

Brian FitzGerald

unread,
Aug 6, 2009, 1:11:25 PM8/6/09
to ColdSpring-Users
Hey all, just trying to wrap my head around how I'm going to use
remote proxies to aide me in some upcoming ajax development.

So my app has a ColdSpring driven model, and I've read the doco on
setting up my remote proxies. That looks simple enough. Since my
application typically passes stuff back from my service layer as
either business objects or queries though, I'm wondering what people
typically do to get this data back as xml when methods are called
directly on the remote proxies.

So for example, if I have a call in my UserService called getUsers,
that typically returns a query, in my RemoteUserService, I'm thinking
I'll want to have these users come back as xml so that I can handle
everything in the javascript callback. How is this typically handled?

Thanks!
Brian

Barney Boisvert

unread,
Aug 6, 2009, 2:25:18 PM8/6/09
to coldspri...@googlegroups.com
You can use the returnformat parameter to control how the CFC emits
data when invoked remotely, though there isn't an XML format supported
(aside from WDDX). If your going to JavaScript, however, I'd
recommend JSON instead of XML.

cheers,
barneyb
--
Barney Boisvert
bboi...@gmail.com
http://www.barneyb.com/

Tony Nelson

unread,
Aug 6, 2009, 2:25:27 PM8/6/09
to coldspri...@googlegroups.com
I would recommend using JSON rather than XML. That way you can use both serializeJSON(users) as well as <cffunction name="getUsers" returnFormat="json">

-Tony

Brian FitzGerald

unread,
Aug 7, 2009, 11:11:55 AM8/7/09
to ColdSpring-Users
Thanks much, guys. I hadn't really looked into the returnformat
attribute up to this point, but it looks like that's what I need.

Best,
Brian



On Aug 6, 2:25 pm, Tony Nelson <tonynelso...@gmail.com> wrote:
> I would recommend using JSON rather than XML. That way you can use both
> serializeJSON(users) as well as <cffunction name="getUsers"
> returnFormat="json">
>
> -Tony
>
> On Thu, Aug 6, 2009 at 12:11 PM, Brian FitzGerald
> <bmfitzgera...@gmail.com>wrote:

Brian FitzGerald

unread,
Aug 7, 2009, 8:10:38 PM8/7/09
to ColdSpring-Users
I actually have a couple follow up questions. I have successfully
been able to invoke my methods which return multiple items, such as
getUsers(). The format of the json response is as if I had called
SerializeJSON with serializeQueryByColumns set to false. This format
seems a bit cumbersome to work with though, so I'm wondering if there
is a way to retrieve the result set as if I had set
serializeQueryByColumns to true. The call is being made quite simply
from jQuery:

$.getJSON("http://mysite.loc/model/services/RemoteUserService.cfc?
method=getUsers&returnformat=json", { }, myCallback);

I tried appending an additional argument to the end of the url with no
success:
$.getJSON("http://mysite.loc/model/services/RemoteUserService.cfc?
method=getUsers&returnformat=json&serializeQueryByColumns=true", { },
myCallback);

Is anyone aware if there is a way to acheive this considering I'm not
actually using the SerializeJSON method?

My next question is that, while I can successfully retrieve complete
query results as json, I cannot successfully return a User business
object. When I try this, the result comes back as an empty string
rather than a json representation of the cfc. To dig into this a bit
further, rather than calling the method via jQuery, I called the
method via a direct cfinvoke of the Web service and noticed that the
result appeared to be a Java object rather than a simple cfc. Might
this be part of the problem?

I would be most appreciative if anyone could point me in the right
direction on these.

Best,
Brian
Reply all
Reply to author
Forward
0 new messages