Amit
Amit

Reputation: 2130

grails return xml string from controller

In a gaming app we are using grails to for all serve side interactions. In one case we want to save and retrieve game state form the server. I am assuming game app which will be in Unity 3D will make url request from the app its downloaded from and controller inturn will only return xml String. Will the following code be sufficient. Some how data is not reflected in the gaming app from where this request is called. Though we can see the url called correctly.

render outxml
         return false

Upvotes: 0

Views: 734

Answers (2)

Teejay
Teejay

Reputation: 51

This worked for me:

def search(String property, String value) {
def c = Stmt.createCriteria()
def xml = c.list {like property, "%$value%"}
render(text: xml.stm[0], contentType: "text/xml", encoding: "UTF-8")

and then called like this:

http://localhost:8080/search?property=account&value=876543291&description=test&entries=20

Upvotes: 2

David
David

Reputation: 1970

If outxml is a String (or GString) that contains the XML response you want then render outxml should work fine. You shouldn't need to have a return statement in this case.

Is there a particular reason you're returning false? what are you trying to achieve?

Upvotes: 0

Related Questions