Tony Stew

Tony Stew

  • NA
  • 1
  • 590

XML attributes instead of elements in data contract serialis

Apr 21 2015 12:36 AM

I want to uses XML attributes instead of elements, I implemented IXmlSerializable and

public partial class Id : IXmlSerializable {

/// <remarks/> [XmlAttribute] public string lmsId;  /// <remarks/>  [XmlAttribute] public string unitId;  /// <remarks/>  [XmlAttribute] public string lmsPresId;  /// <remarks/>  [XmlAttribute] public string callId;  public System.Xml.Schema.XmlSchema GetSchema() {     return null; }  public void ReadXml(System.Xml.XmlReader reader) {     //implement if remote callers are going to pass your object in }  public void WriteXml(System.Xml.XmlWriter writer) {     writer.WriteAttributeString("lmsId", lmsId.ToString());     writer.WriteAttributeString("unitId", unitId.ToString());     writer.WriteAttributeString("lmsPresId", lmsPresId.ToString());     writer.WriteAttributeString("callId", callId.ToString()); }

}

But my service help is showing request and response as unknown


I tried even XmlSerializerFormat public partial class Id : IXmlSerializable {

/// <remarks/> [XmlAttribute] public string lmsId;  /// <remarks/>  [XmlAttribute] public string unitId;  /// <remarks/>  [XmlAttribute] public string lmsPresId;  /// <remarks/>  [XmlAttribute] public string callId;  public System.Xml.Schema.XmlSchema GetSchema() {     return null; }  public void ReadXml(System.Xml.XmlReader reader) {     //implement if remote callers are going to pass your object in }  public void WriteXml(System.Xml.XmlWriter writer) {     writer.WriteAttributeString("lmsId", lmsId.ToString());     writer.WriteAttributeString("unitId", unitId.ToString());     writer.WriteAttributeString("lmsPresId", lmsPresId.ToString());     writer.WriteAttributeString("callId", callId.ToString()); }

}

then I am getting everything in the xml as xmlElements instead of XmlAttributes But I am getting all the data as elements instead of Xmlattributes