Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 6th, 2008, 06:08 PM
Member
 
Join Date: Mar 2008
Posts: 55
Default XML Serialization in .NET

Hey All,
I am using a C# client that generates xml that then gets sent via a web service to a java web service server side. In this case, we are creating the messages ourselves, based on the contract defined by the java wsdl.

I am looking for some advice on what the best approach is for this. Currently, on the client, my classes for Objects just wrap xml. This means If I had a person object, and I did:
Person p = new Person(PersonElement);
p.firstName;
p.firstName = "NewName";

the getter would be actually running an xpath to the attribute, and the same with the set. When I want the xml output, it's simple because I just get the Element that the object is wrapping.

However, this seems like it would be expensive compared to using an object, and then just serializing/deserializing when needed.

I have played around a little with XMLSerializer, and I have looked at DataContractSerializer. Problem with DCS is that you cannot specify what is an attribute, and what is an element.

Is there anything in .NET similar to JAXB in java, or is XMLSerializer the closest thing?

Thanks so much!
Reply
  #2  
Old October 7th, 2008, 01:56 AM
joedeene's Avatar
Site Addict
 
Join Date: Jul 2008
Location: US of A
Posts: 587
Default

Quote:
Originally Posted by nelsonbrodyk
Hey All,
I am using a C# client that generates xml that then gets sent via a web service to a java web service server side. In this case, we are creating the messages ourselves, based on the contract defined by the java wsdl.

I am looking for some advice on what the best approach is for this. Currently, on the client, my classes for Objects just wrap xml. This means If I had a person object, and I did:
Person p = new Person(PersonElement);
p.firstName;
p.firstName = "NewName";

the getter would be actually running an xpath to the attribute, and the same with the set. When I want the xml output, it's simple because I just get the Element that the object is wrapping.

However, this seems like it would be expensive compared to using an object, and then just serializing/deserializing when needed.

I have played around a little with XMLSerializer, and I have looked at DataContractSerializer. Problem with DCS is that you cannot specify what is an attribute, and what is an element.

Is there anything in .NET similar to JAXB in java, or is XMLSerializer the closest thing?

Thanks so much!
Well, for one, this seems to me that it is in the wrong forum. Also, have a look at this MSDN site for the XmlSerializer Class. Ya, just read that and see what you think...

joedeene
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles