469,600 Members | 2,367 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

XmlSerializer not serializing Booleans or Integers?

Hi,

My vb.net project sends an Input object to a webservice and retrieves
a Results object.

The webservice is maintained by a third party, and is pretty huge.

I am using the following procedure to serialize both the input and
result objects to Xml:

Public Function Serialize(Of T)(ByVal obj As T) As String
Try
Dim returnXML As String = String.Empty
Dim serializer As New
Serialization.XmlSerializer(GetType(T))
Using writer As New IO.StringWriter
serializer.Serialize(New XmlTextWriter(writer), obj)
returnXML = writer.ToString()
End Using
Return returnXML
Catch ex As Exception
Msgbox(ex.ToString)
End Try
End Function

The Xml generated from the Results object includes Integers and
Booleans. My problem is the Input object (although is enumerated with
correct values) does not seem to serialize any integers or booleans to
Xml (strings are fine).

Is there anything obvious I should be looking out for?

Thanks
Feb 5 '08 #1
2 3762
"SiJP" <si**********@gmail.comwrote in message
news:82**********************************@s12g2000 prg.googlegroups.com...
The Xml generated from the Results object includes Integers and
Booleans. My problem is the Input object (although is enumerated with
correct values) does not seem to serialize any integers or booleans to
Xml (strings are fine).

Is there anything obvious I should be looking out for?
Are your integers an booleans marked as "public"? The XmlSerializer does
not serialize private fields. Also, if they are properties, I think I
remember having read that they should be read/write (have a get and a set
accessor) if they are to be serialized by the XmlSerializer.

There is an article on MSDN on Troubleshooting the XmlSerializer:
http://msdn2.microsoft.com/en-us/library/aa302290.aspx
Feb 5 '08 #2

Check my blog here:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!114.entry

I added a bool property to the "State" object. (State, as in NC, VA, AK).

And it serializes and deserializes correctly.

But mine is 1.1 code, and not "Generic"'ed up.....


"SiJP" <si**********@gmail.comwrote in message
news:82**********************************@s12g2000 prg.googlegroups.com...
Hi,

My vb.net project sends an Input object to a webservice and retrieves
a Results object.

The webservice is maintained by a third party, and is pretty huge.

I am using the following procedure to serialize both the input and
result objects to Xml:

Public Function Serialize(Of T)(ByVal obj As T) As String
Try
Dim returnXML As String = String.Empty
Dim serializer As New
Serialization.XmlSerializer(GetType(T))
Using writer As New IO.StringWriter
serializer.Serialize(New XmlTextWriter(writer), obj)
returnXML = writer.ToString()
End Using
Return returnXML
Catch ex As Exception
Msgbox(ex.ToString)
End Try
End Function

The Xml generated from the Results object includes Integers and
Booleans. My problem is the Input object (although is enumerated with
correct values) does not seem to serialize any integers or booleans to
Xml (strings are fine).

Is there anything obvious I should be looking out for?

Thanks

Feb 5 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andy Neilson | last post: by
2 posts views Thread by Aleksei Guzev | last post: by
1 post views Thread by Ivo Bronsveld | last post: by
1 post views Thread by Derrick | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.