XML Serialization in .NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelsonbrodyk
    New Member
    • Mar 2008
    • 81

    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(PersonEl ement);
    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 DataContractSer ializer. 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!
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    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(PersonEl ement);
    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 DataContractSer ializer. 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

    Comment

    Working...