serialization, deserialization and serialization again?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andreas Zita

    #1

    serialization, deserialization and serialization again?

    In my ws I have a method that serializes a simple custom object with some
    properties. On the other side, in my aspx application, the object is
    received and deserialized nicely by .net.

    But the problem is that i don't _want_ .net to deserialize the returning
    xml. The serialized xml text is exactly what I want because Im only going to
    feed that string into a simple "Xml Web Control" and then attach a
    stylesheet file to it. Im a bit new to this but shouldnt this be very very
    simple? At the moment Im doing a work-around and serializing the stupid
    object _back_ to xml again and something tells me I shouldnt need to do
    that? Since its allready there in the soap response i mean ... but thow do I
    get hold of it in aspx .net?

    Continuing ...

    My first approach was to try and make use of the deserialized object instead
    somehow but unfortunately the deserialized object didnt actually have
    exactly the same structure as my original object. The properties (get/set)
    in my original object had been exchanged for simple variables which then
    didnt allow me to use this object as a datasource etc. So that approach left
    me with nothing. I really dont get this, why serialize and deserialize if
    whats left isnt the same as the original anyway?


  • richlm

    #2
    Re: serialization, deserialization and serialization again?

    You could serialize your custom class instance to XML inside your web method
    on the server using XmlSerializer and then pass it to the caller as a string
    (instead of as an instance of your custom class).


    Comment

    • Dino Chiesa [Microsoft]

      #3
      Re: serialization, deserialization and serialization again?

      This idea will work, however you will inflate your payload by escaping all
      the angle brackets etc.

      Another approach is to define the interface as passing an xsd:any, if you
      start with WSDL/XSD, or decorating one part of the response message with
      [XmlAny], if you start with ASMX. On the receiving (caller) side, you will
      get back an instance of XmlElement. At this point you can directly get the
      Xml from the XmlElement without going through an XmlSerializer.

      For more on this technique check out this article:
      http://msdn.microsoft.com/library/en...ce04162003.asp

      or google around for XmlAnyElement

      -Dino



      "richlm" <rich_lm@h0tmai 1.com> wrote in message
      news:O5GUKyuqEH A.1296@TK2MSFTN GP12.phx.gbl...[color=blue]
      > You could serialize your custom class instance to XML inside your web
      > method on the server using XmlSerializer and then pass it to the caller as
      > a string (instead of as an instance of your custom class).
      >
      >[/color]


      Comment

      Working...