[Italian version]
An implicit features of the serialization of framework 2.0 is to have null xml elements using xml standard format, xsi:nil. This possibility is given by nullable types. Today the xml is considered the king of interoperability format between different systems. In the near future a possibile scenario could be to have a server that publish web services implemented with framework 2.0 and consumed from client using framework 1.x. Of course, this is possibile! But what happen if server use nullable types in its services? The proxy class is generated client-side without problems. The nullable types is not present in framework 1.x and so the nullable elements is mepped as not-nullable types (e.g. bool instead bool?). It seems to go well at runtime too but when client receive a null element the serialization 1.x is not able to read it and we have an error.
I think that many people will say that xml of framework 2.0 is not compatible with framework 1.x... really we must say that serialization of 1.x has a lower potential - it seems obvious. For this reason we must be more careful!
How to solve it? NullableTypes of Luka are an excellent solution for the problem! The NullableTypes implement IXmlSerializable. They have a customized xml serialization that is in keeping with native nullable types of framework 2.0! That's cool! :-D We must create proxy class for web services with VS2003 and we must customize the code. We must replace nullable value type with luka's NullablesTypes.
The interoperability is valid vice versa. A web server that publish web service implemented with framework 1.x can use NullableTypes. A client application implemented with framework 2.0 can consume those services without problems . The code of proxy class is generated without problem but the nullabletypes are not recognized. They appears as XmlElement. We must only replace XmlElement with Nullable<T> realated to the required type. That's all!
posted @ lunedì 7 novembre 2005 10:37