ServicesResourcesConferencesOur TeamWeblogsAboutContact
   

Subscriptions

Post Categories

Affiliations

Archives

IXmlSerializable rules

Yesterday a customer got in touch with me regarding some custom serialization/deserialization issues in his ASMX-based Web Services.

When using IXmlSerializable there are essentially three 'rules' to follow:

  • In WriteXml
    • Don't ever write the root element, but have it specified as XmlRoot. The XmlSerializer instance will create the root element (or SOAP body will replace the root with whatever name it bears)
  • In ReadXml
    • Pretend the root is always there
  • On schema imports
    • Avoid the duplicate global element problem: check to make sure that the schema isn't already in the SchemaSet
      if(!schemaSet.Contains(mySchema.Id)) { schemaSet.Imports.Add(mySchema); }

Nothing spectacular, just to keep in mind.
Here is a great post by Kirk to look at if you want to deal with IXmlSerializable.

BTW: IXmlSerializable stays important in WCF land: go and read the invaluable serialization rules by Sowmy. So, it rulez :)

posted on Tuesday, May 23, 2006 9:50 PM

# Interesting Finds: May 23, 2006 PM edition @ Wednesday, May 24, 2006 1:46 AM


Jason Haley

# Link Listing - May 23, 2006 @ Wednesday, May 24, 2006 4:41 AM


A refresh button for asp.net pages [Via: pvanooijen ]
ASP.NET 2.0 Fix That Everyone Needs [Via:...
Christopher Steen


Powered by Community Server, by Telligent Systems