473,672 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.X mlSerializer(Ge tType(T))
Using writer As New IO.StringWriter
serializer.Seri alize(New XmlTextWriter(w riter), obj)
returnXML = writer.ToString ()
End Using
Return returnXML
Catch ex As Exception
Msgbox(ex.ToStr ing)
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 4008
"SiJP" <si**********@g mail.comwrote in message
news:82******** *************** ***********@s12 g2000prg.google groups.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.space s.live.com/Blog/cns!A68482B9628 A842A!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"'e d up.....


"SiJP" <si**********@g mail.comwrote in message
news:82******** *************** ***********@s12 g2000prg.google groups.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.X mlSerializer(Ge tType(T))
Using writer As New IO.StringWriter
serializer.Seri alize(New XmlTextWriter(w riter), obj)
returnXML = writer.ToString ()
End Using
Return returnXML
Catch ex As Exception
Msgbox(ex.ToStr ing)
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

4
11380
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 should have worked fine since the class in question was already being serialized and deserialized as part of a Web service interface. What I found was that by deserializing from an XmlNodeReader instead of an XmlTextReader, XML Serialization doesn't work...
2
3291
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from ‘DataItem’ public class DataItem { public DataItem() {}
3
3167
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 the server (W2K3) it throws an exception. It only seems to happen when serializing/deserializing _arrays_ of a type. If I just serialize/deserialize one instance, it works fine. The exception I get is: (sorry for the word wrapping.)...
1
2082
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I created a couple of objects and serializing it into XML based upon the schema works perfectly. The XML / Schema looks something like this:
3
10401
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 the road. It would be awesome somebody could answer this, sadly most of my questions don't get answered. Regards,
1
1707
by: Derrick | last post by:
Hello all; I seem to be having some trouble serializing a class to XML. This code is a cut & paste from a project which used it perfectly, but all of a sudden I'm getting an error that the "dll ogerh_f6.dll or one of its dependancies cannot be found". The class I'm serializing is quite simple, with a couple of string properties marked with the XmlElementAttribute. The class is marked with the Serializable attribute. As such, I don't...
0
950
by: Carlo, MCP | last post by:
Good morning, sorry for the lenght of the code, but it's six months that I've this problem. The following code is an extreme simplification of the original code, that is much more complex. The problem, however, occours in the following code at all. It's easy copy the following code for reproducing the problem. This is a class that simply draws (or not draws) a blue rectangle inside a given Rectangle:
10
4777
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 value for the parameter of an SqlCommand for inserting the xml document in a column of a table where the column is typed to be of the same xml schema. This all sounds simple, but SQL Server REQUIRES the timezone to be specified for date values....
2
1557
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 procedure to serialize both the input and result objects to Xml:
0
8485
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.