Monday, May 18, 2009

A tricky problem for xml validation

There's an interesting article about XML Schema nillable=”true” vs minOccurs=”0″ in Dimithu's blog. minOccurs is an xml attribute that most people understand; but for nillable="true", people might understand its meaning; however, how to use it in a correct way is not well known. By "correct way", I mean "the way that complies with W3C specifications".
Actually, a lot of software vendors are not clear about its usage as well. This leads to interoperability problems. Some BPM/SOA vendors implement different validation rules for a "nillable" tag, which are not in accordance with W3C specifications. 

Imagine an application is built which utilizes web services from different external system, and those web services require web service validation. The problem occurs that some systems send out the message which they consider as valid, while it's rejected by other systems due to different interpretation of "wsdl/soap validity". 

In short, the problem can be described as follows:
When an element is defined in wsdl using  xs:element name="nilint" nillable="true" type="xs:int"

The nilint element in the soap message should look like this if it's an empty node:
nilint xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/
If it's not an empty node, we can remove the contained attribute because by default the value for nil is "false".

Considering the aforementioned scenario, if some development tools that are used to build the SOA application don't provide support for the nil tag, we need to find some way to workaround the issue. The normal way to do it is to create an interceptor class whenever the soap message is being sent out.
This looks like a minor issue, but indeed a lot tools have problems with it; for example, wsdl validation function in SoapUI does not work in a correct way.

No comments: