Microsoft 'NET Framework and XML Serialization Advanced Saqib Rasool Developer Support Engineer PSS - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Microsoft 'NET Framework and XML Serialization Advanced Saqib Rasool Developer Support Engineer PSS

Description:

SOAP and Binary Serialization with Formatters ... formatters are found under the System.Runtime.Serialization.Formatters namespace ... – PowerPoint PPT presentation

Number of Views:525
Avg rating:3.0/5.0
Slides: 25
Provided by: MicrosoftC2
Category:

less

Transcript and Presenter's Notes

Title: Microsoft 'NET Framework and XML Serialization Advanced Saqib Rasool Developer Support Engineer PSS


1
Microsoft .NET Framework and XML Serialization
(Advanced) Saqib RasoolDeveloper Support
EngineerPSS XML WebData Team Microsoft
Corporation
2
Agenda
  • Serialization recap
  • Serialization example
  • Customizing serialization
  • Creating SOAP messages
  • Usage of SOAP with serialization
  • Note These slides provide only a summary. Read
    the transcript or listen to the on-demand
    recording of this WebCast for in-depth
    information about this subject. Microsoft
    Knowledge Base article Q323503, WebCast XML
    Serialization and Sample Code contains a full
    code sample.

3
Serialization Recap
  • Object serialization
  • Saving/archiving an object to portable media
  • Into a file, into memory, or straight to wire
  • Deserialization
  • Restructuring saved/archived object into a memory
    lived object
  • System.Xml.Serialization namespace
  • XmlSerializer class
  • XmlSerializer.Serialize(..)
  • XmlSerializer.Deserialize(..)

4
Serialization Example

5
Serialization ExampleSerialized Object

6
Serialization ExampleDeserializing

7
Serialization CustomizationsEarly Customizations
  • Use attributes to control the serialization
  • Example XmlElementAttribute


8
Serialization Customizations (2)Early
Customizations
  • Use attributes to control the serialization
  • Example XmlRootAttribute


9
Serialization CustomizationsAllowed
Customizations Using Attributes
  • Use attributes to control the serialization


10
Serialization CustomizationsLate Customization
  • Can use attributes to change XML stream
  • Late customization is needed when modifying the
    original source code is not an option
  • See code on next slide


11
Changing Output XML Stream with Overriding
12
Before overriding
Changing Output XML Stream with Overriding (2)
After overriding
  • You can also override the class used for
    serialization

13
Creating SOAP Messages
  • The XmlSerializer can be used to generate
    SOAP-encoded messages
  • Process
  • SoapReflectionImporter. ImportTypeMapping(..)
    creates XmlTypeMapping
  • Create XmlSerializer by passing above
    XmlTypeMapping
  • Call XmlSerializer.Serialize() and
    XmlSerializer.Deserialize() as needed


14
Creating SOAP MessagesCode Sample
15
SOAP-Encoded XML Stream
16
Customizing SOAP Messages
  • Customized and overridden in the same way as
    regular serialization
  • These attributes are used for customization


17
Customizing SOAP MessagesCode Sample
18
Usage of SOAP with SerializationWeb Services
  • Web Services use SOAP as the underlying mechanism
  • XmlSerializer is used to create those SOAP-
    encoded methods
  • Previously described techniques can be used to
    change the output message format of the Web
    Service


19
SOAP Customization in Web ServicesCode Sample
20
SOAP Customization in Web ServicesSOAP Envelope
for Calling Web Service
21
SOAP and Binary Serialization with Formatters
  • SoapFormatter and BinaryFormatter are different
    than the techniques discussed earlier do not
    confuse these with XmlSerializer
  • These formatters are found under the
    System.Runtime.Serialization.Formatters namespace
  • These are used when full object fidelity is
    required
  • BinaryFormatter is used for providing a compact
    stream
  • SoapFormatter is used for portability

22
Binary Formatter Code Sample
23
SOAP Formatter Code Sample
24
  • Thank you for joining us for todays Microsoft
    Support
  • WebCast.
  • For information about all upcoming Support
    WebCasts
  • and access to the archived content (streaming
    media
  • files, PowerPoint slides, and transcripts),
    visit
  • http//support.microsoft.com/webcasts/
  • We sincerely appreciate your feedback. Please
    send any
  • comments or suggestions regarding the Support
  • WebCasts to supweb_at_microsoft.com.
Write a Comment
User Comments (0)
About PowerShow.com