Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best practice using XML and XSDs to map against database

Status
Not open for further replies.

golcarlad

Programmer
Nov 23, 2004
232
0
0
GB
We have a ReST Web Service that uses POST - to insert data into database (unmarshall data from XML), and GET to retrieve data (marshalled into XML).

An XSD is used to create Java objects to marshall/unmarshall data to and from a database. We kind of froze the XSD as it is, because we thought this models the data perfectly - and it does, but only for posting data really.

Now comes the time to GET data from the database, I find myself having to "break" our current XSD and allow it to publish primary keys and other data values that. POST-type requests don't care about these other values!

So - in effect the XSD now has optional elements in it (only used for GET requests). This could cause potential confusion when you have to explain to 3rd parties who want to use your web service and you have this XSD that has a kind of split personality between getting and posting data. It also doesn't feel clean and elegant as it used to.

What should I do? Is it OK to have elements in your XSD that are only used in a certain circumstances (like getting data)? Or should I have 2 XSDs - one more verbose, tailored to GET requests and one slimmed down, purely for POST request??

Your help and advice - much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top