0

I was reading through the following example

RESTful on Play! framework

The one thing I am not sure about is the code here regarding and http POST

<user>
   <name>${user.name}</name>
   <dob>${user.dob}</dob>
   <somethign>${user.something}</something>
   <another>${user.another}</another>
   .... etc etc
</user>

What if the playframework is only given this xml during an http POST? (will the playframework break in this case)

Dean asdf

Notice that two fields were optional and not given. Does playframework still work in this case?

thanks, Dean

Community
  • 1
  • 1
Dean Hiller
  • 17,183
  • 19
  • 103
  • 176
  • Dean, sorry, but I completely don't understand what are you asking about. This is some sample of template, you can use what you want/need to render. BTW nowadays maybe it's better to use Json? Which version of Play are you using/going to use? – biesior May 30 '12 at 14:38
  • I am trying to do a POST of xml data. I thought maybe the template helped in mapping the post data back to the bean. If the template is not the one telling playframework the mapping, who is? Where do I specifiy the mapping of my xml TO the User bean passed into the static post method in my controller? – Dean Hiller May 30 '12 at 19:16
  • The code you showed is just a snippet from some view, which is used for generating XML file. As it's Groovy I assume that you're using Play 1.x in such case: http://www.playframework.org/documentation/1.2.4/libs#ParsingXMLusingXPath I'm afraid you need to parse the sent POST to bind it to some object manually (note: I don't use P1 and prefer Json for my APIs so it could be not quite accurate answer) – biesior May 30 '12 at 19:23
  • how do I get the body as a String then? I didn't seem to see that and yes I am using play 1.2.4 – Dean Hiller May 30 '12 at 21:18

1 Answers1

2

Glad that we found basic agreement :)

I think that the Coffee Bean's post is that you are looking for.

biesior
  • 54,554
  • 10
  • 118
  • 177