I was thinking alot about REST and service versioning again today. In my previous blog I talked a bit about using the media type and probably XML schema to guarantee a contract between the client and server. The client would ask for “application/vnd1+xml” and be all set for its conversation to begin.
The big problem I see with this is a service maintenance problem. As you rev your service and your schema you’re going to have to support a lot of different media types. What would make things easier is if XML Schema supported polymorphism. That way a client could ask for “application/vnd1+xml” format and still receive and validate a newer version of the schema. Please correct me if I’m wrong, but I don’t think you can do this in XML schema. Yes you could extend various types from the parent to create a newer version of a schema, but a validator would not be able to enforce a polymorphic relationship with its parent AFAIK.
Clients and servers could get around this XSD problem by not doing validation and hoping that the schema developers are disciplined enough to make future versions of the format backward compatible. It just seems incomplete to me to not be able to validate.
Mar 31, 2009 @ 14:05:35
You might be able to achieve this by defining the base types (for polymorphism) in one schema, and the concrete types in a different schema that you could version. For example, in Listing 2 of http://www.ibm.com/developerworks/xml/library/ws-tip-xsdchoice.html the “Payment” type could be defined in NS1, while “CashPayment”, “CreditPayment”, and “CheckPayment” could be defined in NS2 (yet still extend NS1:Payment). NS2 could be versioned as needed, but you’d want to limit the changes to NS1.
The downside of this approach is that its very verbose, complex, and it may not even solve the problem in all cases.
Apr 02, 2009 @ 03:07:26
Do some people do schema validation? I’ve never met any yet. Ok, I’m young but still.
Apr 07, 2009 @ 05:54:36
In the past, I have done xs:Any all over the place to allow for future changes. Oh, the horror 😉
(all so it could still validate).
Hypermedia: making it easier to create dynamic contracts « Guilhermesilveira's Blog
Dec 08, 2009 @ 11:25:06
Hipermídia e contratos dinâmicos: menor acoplamento | blog.caelum.com.br
Dec 17, 2009 @ 12:07:54