473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1545
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
Hey, I have made a method that would take any object o and an array of extraTypes to construct a XmlSerializer object then call .Serialize(stream, object)... When I have this called within...
8
by: Harris Boyce | last post by:
Hello, I'm trying to use the FOR XML EXPLICIT clause with SQL Server to deserialize data from my database into a strongly-typed collection object that I will use throughout my application. I...
3
by: Anthony Bouch | last post by:
Hi I've been reading using the XmlSerializer with custom collections. I've discovered that when serializing a custom collection (a class that implements ICollection, IList etc.) the...
4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
3
by: Don McNamara | last post by:
Hi, I've hit quite a strange problem with XmlSerializer on my W2K3 server. When I serialize/deserialize using an exe on my local computer (XP), everything works fine. When I put the code out on...
3
by: stax | last post by:
Hello, can somebody tell me how to serialize/deserialize a object containing a multi line string using the XmlSerializer class. One of the both windows linefeed chars get dumped somewhere down...
6
by: geoffrobinson | last post by:
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new...
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
2
by: SiJP | last post by:
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...
5
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I am using XML serialization for the first time and I have noticed something unexpected. The object I am serializing contains a field private NumericSettings _numericSettings; public...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.