SoapFormatter Class

Serializes and deserializes an object, or an entire graph of connected objects, in SOAP format.

System.Object
  System.Runtime.Serialization.Formatters.Soap.SoapFormatter

Namespace:  System.Runtime.Serialization.Formatters.Soap
Assembly:  System.Runtime.Serialization.Formatters.Soap (in System.Runtime.Serialization.Formatters.Soap.dll)

[<Sealed>]
type SoapFormatter =  
    class 
        interface IRemotingFormatter 
        interface IFormatter 
    end

The SoapFormatter type exposes the following members.

  NameDescription
Public methodSoapFormatter()Initializes a new instance of the SoapFormatter class with default property values.
Public methodSoapFormatter(ISurrogateSelector, StreamingContext)Initializes a new instance of the SoapFormatter class with the specified ISurrogateSelector and StreamingContext.
Top

  NameDescription
Public propertyAssemblyFormatGets or sets the behavior of the deserializer with regards to finding and loading assemblies.
Public propertyBinderGets or sets the SerializationBinder that controls the binding of a serialized object to a type.
Public propertyContextGets or sets the StreamingContext used with this SoapFormatter.
Public propertyFilterLevelGets or sets the TypeFilterLevel of automatic deserialization for .NET Framework remoting.
Public propertySurrogateSelectorGets or sets the SurrogateSelector that controls type substitution during serialization and deserialization.
Public propertyTopObjectGets or sets the ISoapMessage into which the SOAP top object is deserialized.
Public propertyTypeFormatGets or sets the format in which type descriptions are laid out in the serialized stream.
Top

  NameDescription
Public methodDeserialize(Stream)Deserializes the data on the provided stream and reconstitutes the graph of objects.
Public methodDeserialize(Stream, HeaderHandler)Deserializes the stream into an object graph with any headers in that stream being handled by the given HeaderHandler.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSerialize(Stream, Object)Serializes an object or graph of objects with the specified root to the given Stream.
Public methodSerialize(Stream, Object, Header[])Serializes an object or graph of objects with the specified root to the given Stream in the SOAP Remote Procedure Call (RPC) format.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

NoteNote

Beginning with the .NET Framework 2.0, this class is obsolete. Use BinaryFormatter instead.

The SoapFormatter and BinaryFormatter classes implement the IRemotingFormatter interface to support remote procedure calls (RPCs), and the IFormatter interface (inherited by the IRemotingFormatter) to support serialization of a graph of objects. The SoapFormatter class also supports RPCs with ISoapMessage objects, without using the IRemotingFormatter functionality.

During RPCs, the IRemotingFormatter interface allows the specification of two separate object graphs: the graph of objects to serialize, and an additional graph that contains an array of header objects that convey information about the remote function call (for example, transaction ID or a method signature). For proper serialization, the root object of the first graph must be an object that implements either the IMethodCallMessage interface or the IMethodReturnMessage interface.

During deserialization of an RPC, a HeaderHandler delegate is specified to the Deserialize method of the formatter. The remoting infrastructure uses the HeaderHandler delegate to produce an object that supports the ISerializable interface. This object contains the information stored in the headers, and becomes the root of the graph returned by the deserializer.

The SoapFormatter can also handle RPCs that are produced with objects that implement the ISoapMessage interface. To create an RPC without using the IRemotingFormatter functionality, place an object that supports the ISoapMessage interface at the root of a graph being serialized. To deserialize an RPC created in this manner the TopObject property must be set to another object that supports the ISoapMessage interface, and contains the relevant remote call information.

TimeSpan Serialization

TimeSpan objects are serialized according to the ISO 8601: 1998 section 5.5.3.2.1 "Alternative" standard.

Version Information

The SoapFormatter does not support serialization compatibility between versions of the .NET Framework. Serialization between versions 1.1 and 2.0 types in the Framework often fails. The following actions can be taken to remedy this issue:

  • Convert to use the BinaryFormatter, which provides compatibility between 1.1 and 2.0.

  • Convert existing persisted data to the new format.

  • Convert all producers and consumers of serialized data to version 2.0.

  • Avoid using types that changed from 1.1 to 2.0.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft