/// <summary> /// Encodes the object in XML. /// </summary> public static XmlElement EncodeXml(IEncodeable encodeable, ServiceMessageContext context) { // create encoder. XmlEncoder encoder = new XmlEncoder(context); // write body. encoder.WriteExtensionObjectBody(encodeable); // create document from encoder. XmlDocument document = new XmlDocument(); document.InnerXml = encoder.Close(); // return root element. return document.DocumentElement; }