REST represenation for xml
i'm building a REST api and debating what format should I use for the xml representation. i know it can be one defined in house but there are also lots for formats. wadl looks interesting but there seems to be a debate about it and it's new as well.
what are the recommendations(best practices for it) ?
As long as it's valid XML that's a start. My general strategy for simple REST/XML services is as follows:
For parsing, you almost certainly want a single, always present root node, e.g. "response", which can contain either a result element or an error element. E.g.:
<response> <result> <answer>5</answer> </result> </response>
The way you structure the results is up to you. You can decide whether to hold data in elemenets as CDATA (text notes, as show above) or as required attributes, e.g.
Another thing that is sometimes useful is to include your original query in the response, e.g.:
<response query="operation=add&a=2&b=3"> .. </response>
That way if you have multiple queries outstanding you can match them back to the original request.