469,945 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

XmlSerializer vs SoapFormatter

Hello,
what is the internal difference between them in FW 2.0?
I'm trying to serialize SqlConnectionInfo from SQL SMO and Soap works just
fine but XML throws an exception

SqlConnectionInfo has SerializableAttribute attribute ????


Nov 21 '05 #1
4 9946
lapas,

The two are incredibly different. Internally, they are separate
programs. You should be more worried about what they do.

XML Serialization will "serialize" (I put it in quotes because it is not
truly serialization, it won't always give you an object that has the same
exact internal state as the one that you serialized) just the public
properties of an object.

Using serialization with the SOAP formatter will actually take the field
values of an object (through reflection) and store all of that information
in the stream passed to you.

Depending on what you are doing, one will be more appropriate than the
other. The XML Serializer is used typically for serializing simple types
across web services, or sending the serialized type to other applications
that won't understand the output that the SOAP or binary formatters will
produce.

Using a proper formatter for serialization should be used in other
scenarios, like when talking to other .NET applications.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"laplas" <la****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
Hello,
what is the internal difference between them in FW 2.0?
I'm trying to serialize SqlConnectionInfo from SQL SMO and Soap works
just
fine but XML throws an exception

SqlConnectionInfo has SerializableAttribute attribute ????

Nov 21 '05 #2
Thank you.
Let me ask you this:
if class has attribute [SerializableAttribute] does it mean that objects of
this class can be serialized by either of XmlSerializer or SoapFormatter?

"Nicholas Paldino [.NET/C# MVP]" wrote:
lapas,

The two are incredibly different. Internally, they are separate
programs. You should be more worried about what they do.

XML Serialization will "serialize" (I put it in quotes because it is not
truly serialization, it won't always give you an object that has the same
exact internal state as the one that you serialized) just the public
properties of an object.

Using serialization with the SOAP formatter will actually take the field
values of an object (through reflection) and store all of that information
in the stream passed to you.

Depending on what you are doing, one will be more appropriate than the
other. The XML Serializer is used typically for serializing simple types
across web services, or sending the serialized type to other applications
that won't understand the output that the SOAP or binary formatters will
produce.

Using a proper formatter for serialization should be used in other
scenarios, like when talking to other .NET applications.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"laplas" <la****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
Hello,
what is the internal difference between them in FW 2.0?
I'm trying to serialize SqlConnectionInfo from SQL SMO and Soap works
just
fine but XML throws an exception

SqlConnectionInfo has SerializableAttribute attribute ????


Nov 21 '05 #3
lapas,

If a class has the serializable attribute on it, then it means that you
can use any class that implements the IFormatter interface to serialize your
class (this means the SOAP formatter and the binary formatter, or any other
formatter, for that matter).

You can attempt to serialize any instance of any class with the XML
Serializer, but the result is not guaranteed to give you an instance with
the same state when deserialized.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"laplas" <la****@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
Thank you.
Let me ask you this:
if class has attribute [SerializableAttribute] does it mean that objects
of
this class can be serialized by either of XmlSerializer or SoapFormatter?

"Nicholas Paldino [.NET/C# MVP]" wrote:
lapas,

The two are incredibly different. Internally, they are separate
programs. You should be more worried about what they do.

XML Serialization will "serialize" (I put it in quotes because it is
not
truly serialization, it won't always give you an object that has the same
exact internal state as the one that you serialized) just the public
properties of an object.

Using serialization with the SOAP formatter will actually take the
field
values of an object (through reflection) and store all of that
information
in the stream passed to you.

Depending on what you are doing, one will be more appropriate than
the
other. The XML Serializer is used typically for serializing simple types
across web services, or sending the serialized type to other applications
that won't understand the output that the SOAP or binary formatters will
produce.

Using a proper formatter for serialization should be used in other
scenarios, like when talking to other .NET applications.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"laplas" <la****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
> Hello,
> what is the internal difference between them in FW 2.0?
> I'm trying to serialize SqlConnectionInfo from SQL SMO and Soap works
> just
> fine but XML throws an exception
>
> SqlConnectionInfo has SerializableAttribute attribute ????
>
>
>
>


Nov 21 '05 #4
If a class has the serializable attribute, it means you can use only
standard serialization. XmlSerializer dosn't take it in account, it
works in a different way.

Nicholas Paldino [.NET/C# MVP] wrote:
lapas,

If a class has the serializable attribute on it, then it means that you
can use any class that implements the IFormatter interface to serialize your
class (this means the SOAP formatter and the binary formatter, or any other
formatter, for that matter).

You can attempt to serialize any instance of any class with the XML
Serializer, but the result is not guaranteed to give you an instance with
the same state when deserialized.

Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jarda | last post: by
4 posts views Thread by Steve Long | last post: by
reply views Thread by cmrchs | last post: by
1 post views Thread by Paul | last post: by
5 posts views Thread by =?Utf-8?B?TWFydHluIEZld3RyZWxs?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.