jeudi, juin 21, 2007

Spring One (day2) : WS-DuckTyping




How to extend the concept of Duck typing to webservices.

Duck typing is a feature of dynamic languages: "if it walks like a duck and sounds like a duck, then its a duck".

Basics are:

  • Don't validate incoming messages

  • Use XPath

  • Don't create stubs and skeletons.



One rule is: sending should be conservative, and receiving liberal.

Schematron seems interesting in this approach because it is based on finding tree patterns (RelaxNG also does this).
More simply, XPath allows to look for an info without assuming that the surroundings (things out of the path) have any strict structure.

Spring WS 1.0 RC2 is out and based on contract-first and XML use without directly doing XML.

There are a lot of cool XML and particularly XPath helpers in this release, even if you don't need to use it for web services.
XPathTemplate, NodeMapper, and annotations make it very handy and easy to use XML with the ability to switch implementations.