Friday, February 14, 2014

WCF and XML serialization

..continued from earlier post

The default DataContractSerializer used in WCF will serialize ‘strings containing control characters with a hexadecimal value below 20 as XML entities.’ This is obviously going to produce invalid XML 1.0.
But it was interesting to find that XML 1.1 spec makes valid ‘the use of character references to the control characters #x1 through #x1F, most of which are forbidden in XML 1.0.’  In fact, it makes all Unicode characters valid. 
[#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]    /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */

I wonder then if we can make WCF use XML 1.1 only? I don’t know – but  as per Whats New in SOAP 1.2 SOAP 1.1 uses XML 1.0, and for SOAP 1.2 ‘it is left to the specification of a binding to an underlying protocol to specify the XML serialisation used in underlying protocol data units. The HTTP binding specified in [SOAP 1.2 - Part 2] uses XML 1.0 as the serialisation of the SOAP message infoset.’ So it may not be readily possible to make WCF use XML 1.1, even if ones decides to support only SOAP 1.2. It’ll require more research

No comments:

Post a Comment