Serializing Object Model

Discussion in 'ASP .Net' started by Dave T, Mar 27, 2008.

  1. Dave T

    Dave T Guest

    I have a generic.list(of T) class that has a property of another class type
    that I want to return form a web service. Everything gets populated OK but
    when I serialize, the property is left out. Any ideas?


    Below, the property in question is "UserInputAddress". In the web service,
    just before the serialization, I am able to address the property and it's
    components have values.

    Namespace DataStructure
    <System.Xml.Serialization.XmlRoot("Addresses")> _
    <Serializable()> _
    Public Class Addresses
    Inherits System.Collections.Generic.List(Of Address)

    ....

    Private _UserInputAddress As New SearchInput
    Public Property UserInputAddress() As SearchInput
    Get
    Return _UserInputAddress
    End Get
    Set(ByVal value As SearchInput)
    _UserInputAddress = value
    End Set
    End Property

    ....

    End Class
    End Namespace

    Namespace DataStructure
    <Serializable()> _
    Public Class Address

    .... A bunch of properties...

    End Class
    End Namespace

    <WebMethod()> _
    Public Function SearchByCountyStreet(ByVal County As String, ByVal
    Street As String) As System.Xml.XmlDocument
    Dim _XML As New System.Xml.XmlDocument
    Dim _Addresses As New DataStructure.Addresses
    Dim _Serializer As New
    System.Xml.Serialization.XmlSerializer(GetType(DataStructure.Addresses))
    Dim _Writer As New System.IO.StringWriter
    _Addresses.UserInputAddress.Jurisdiction = County
    _Addresses.UserInputAddress.StreetName = Street
    _Addresses.GetAddressesByCountyStreet()
    _Serializer.Serialize(_Writer, _Addresses)
    _XML.LoadXml(_Writer.ToString)
    Return _XML
    End Function


    XML(I want to see a "UserInputAddress" element)

    <?xml version="1.0" encoding="utf-8"?>
    <Addresses xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Address>
    <Number>123</Number>
    <Street>this</Street>
    </Address>
    <Address>
    <Number>345</Number>
    <Street>that</Street>
    </Address>
    </Addresses>
    Dave T, Mar 27, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Natan
    Replies:
    5
    Views:
    1,600
    Natan
    Sep 27, 2004
  2. Replies:
    1
    Views:
    483
    Andreas Wollschlaeger
    Oct 6, 2006
  3. Dave T

    Serializing Object Model

    Dave T, Mar 24, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    287
  4. Dave T

    Serializing Object Model

    Dave T, Mar 24, 2008, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    142
  5. Dave T

    Serializing Object Model

    Dave T, Mar 27, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    90
    Dave T
    Mar 27, 2008
Loading...

Share This Page