PDA

View Full Version : Custom CRUD



aaronmars
6 Oct 2011, 11:11 AM
So, I have an existing REST API.

Is it possible to configure the existing classes to work with the data my service is already returning?

GET:/api/users returns this:


<users>
<user>
<id>123</id>
<name>Jane</name>
</user>
<user>
<id>124</id>
<name>Joe</name>
</user>
</users>


For POSTs (create operations), I'd like to post the following to /api/users (note the <users> root tag):


<users>
<user>
<id>125</id>
<name>Jenny</name>
</user>
</users>


For PUTs (update operations), the API expects the following sent to&nbsp;/api/users/123 (note the lack of a <users> root tag):


<user>
<id>123</id>
<name>Jane's new name</name>
</user>


Unfortunately the proxy classes and XmlReader/Writer seem to expect the same XML format.
What's the easiest way to override this?