Soap Serialization

Soap serialization works similarly to binary serialization. First, you need to add a reference to the System.Runtime.Serialization.Formatters.Soap.dll assembly. Then you add an Imports System.Runtime.Serialization.Formatters.Soap directive. At this point you can serialize and deserialize your objects. To continue the example of the typed collection shown in the previous section, write the following code to accomplish serialization with the Soap formatter:

image

Basically there is no difference in the syntax for the Soap formatter if compared to the binary one.

Tip on Generic Collections

The SoapFormatter class does not allow serializing generic collections. This is the reason why a simpler example against a single string is provided.

You can still examine the result of the serialization process with the Windows Notepad. Figure 43.2 shows how the target file stores information in a XML fashion.

Figure 43.2 Examining the result of the Soap serialization process.

image

Typically the Soap serialization is intended to be used when working with Soap web services. If you want to serialize objects in a pure XML mode, you can take advantage of Xml serialization, which is described in the “XML Serialization” section later in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.231.128