How to: Serialize an Object as a SOAP-Encoded XML Stream
Because a SOAP message is built using XML, thecan be used to serialize classes and generate encoded SOAP messages. The resulting XML conforms to section 5 of the World Wide Web Consortium (www.w3.org) document "Simple Object Access Protocol (SOAP) 1.1". When you are creating an XML Web service that communicates through SOAP messages, you can customize the XML stream by applying a set of special SOAP attributes to classes and members of classes. For a list of attributes, see .
To serialize an object as a SOAP-encoded XML stream
Create the class using the.
Apply one or more of the special attributes found in System.Xml.Serialization. See the list in "Attributes That Control Encoded SOAP Serialization."
Create an XmlTypeMapping by creating a new SoapReflectionImporter, and invoking the ImportTypeMapping method with the type of the serialized class.
The following code example calls the ImportTypeMapping method of the SoapReflectionImporter class to create an XmlTypeMapping.
' Serializes a class named Group as a SOAP message. Dim myTypeMapping As XmlTypeMapping = (New SoapReflectionImporter(). _ ImportTypeMapping(GetType(Group))
Create an instance of the XmlSerializer class by passing the XmlTypeMapping to theconstructor.
Call the Serialize or Deserialize method.