T
Tony Johansson
Hi!
The only Xml attribute that I have heard about are those that
start with Xml for example
XmlAttibute but what on are those that start with SOAP. You have
several in the code snippet ?
Has these XmlAttribute that start with SOAP anything to do with
the SOAPformatter ?
using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Xml.Serialization;
public class Company
{
[SoapAttribute(AttributeName = "company")]
public string CompanyName;
[SoapElement(ElementName = "CorporateOffice")]
public string CorporateOffice;
[SoapIgnore]
public string CompanyId;
public override string ToString()
{
string send;
send = "\nCompany name: " + this.CompanyName;
send += "\nCorporate Office: " + this.CorporateOffice;
send += "\nCompany Id: " + this.CompanyId;
return send;
}
public static void Main()
{
string filename = "c:\\Company.soap";
XmlTypeMapping myMapping =
(new SoapReflectionImporter().ImportTypeMapping(
typeof(Company)));
XmlSerializer mySerializer = new
XmlSerializer(myMapping);
Company myCompany = new Company();
myCompany.CompanyName = "Abc Infosystems";
myCompany.CompanyId = "90012";
myCompany.CorporateOffice = "New York";
XmlTextWriter writer = new XmlTextWriter(filename,
Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("CompanyInfo");
mySerializer.Serialize(writer, myCompany);
writer.WriteEndElement();
writer.Close();
XmlTextReader reader =
new XmlTextReader(filename);
reader.ReadStartElement("CompanyInfo");
myCompany = (Company)mySerializer.Deserialize(reader);
reader.ReadEndElement();
reader.Close();
Console.WriteLine(myCompany);
Console.Write("\n\nPress ENTER to exit...");
Console.ReadLine();
}
}
The only Xml attribute that I have heard about are those that
start with Xml for example
XmlAttibute but what on are those that start with SOAP. You have
several in the code snippet ?
Has these XmlAttribute that start with SOAP anything to do with
the SOAPformatter ?
using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Xml.Serialization;
public class Company
{
[SoapAttribute(AttributeName = "company")]
public string CompanyName;
[SoapElement(ElementName = "CorporateOffice")]
public string CorporateOffice;
[SoapIgnore]
public string CompanyId;
public override string ToString()
{
string send;
send = "\nCompany name: " + this.CompanyName;
send += "\nCorporate Office: " + this.CorporateOffice;
send += "\nCompany Id: " + this.CompanyId;
return send;
}
public static void Main()
{
string filename = "c:\\Company.soap";
XmlTypeMapping myMapping =
(new SoapReflectionImporter().ImportTypeMapping(
typeof(Company)));
XmlSerializer mySerializer = new
XmlSerializer(myMapping);
Company myCompany = new Company();
myCompany.CompanyName = "Abc Infosystems";
myCompany.CompanyId = "90012";
myCompany.CorporateOffice = "New York";
XmlTextWriter writer = new XmlTextWriter(filename,
Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("CompanyInfo");
mySerializer.Serialize(writer, myCompany);
writer.WriteEndElement();
writer.Close();
XmlTextReader reader =
new XmlTextReader(filename);
reader.ReadStartElement("CompanyInfo");
myCompany = (Company)mySerializer.Deserialize(reader);
reader.ReadEndElement();
reader.Close();
Console.WriteLine(myCompany);
Console.Write("\n\nPress ENTER to exit...");
Console.ReadLine();
}
}