Web Services and Postel's Law
A recent discussion made me wonder why we insist to treat Web services in a way that ignores Postel’s Law. This is the name a statement originally made under the heading “Robustness Principle” in RFC 793 (hat tip to Mark Pilgrim) goes by:
TCP implementations will follow a general principle of robustness: be conservative in what you do, be liberal in what you accept from others.
This shouldn’t be any different in a Web services scenario, where instead XML messages are received with the expectation to conform to a schema defined in some description language (usually W3C XML Schema + WSDL):
- When a message is received, the receiver should be liberal and accept it if it can somehow work with it.
- When a message is sent, the sender should be conservative; the message should strictly validate against a publicly defined schema.
I’m not sure whether this implies that a more rigid schema language (such as W3C XSD) should be applied and validated against on the sending side, while a more flexible one such as Schematron might be more appropriate on the receiving side. In any case, the level of conservatism introduced by generating and compiling receiver-side code from the schema - at least in the way we do it today - reduces robustness.
A possibly great way - taken in Microsoft’s Indigo to a certain degree, if I understand some earlier samples correctly - would be to generate code only for the subset that is actually used, e.g. specifying what to generate code for by using XPath expressions. Is there an XML binding for Java that works this way? I couldn’t find one within a few minutes.
somehow related is :
http://incubator.apache.org/servicemix/servicemix-bean.html
for example the XPath annotation.
http://fisheye6.cenqua.com/browse/~raw,r=506389/servicemix/tags/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/test/java/org/apache/servicemix/bean/beans/PlainBean.java
… takes the interesting parts of the message and ignores the rest …