what is these Xml attribute that is prefixed with SOAP

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();
}
}
 
A

Arne Vajhøj

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 ?

You can look them up in the docs:

http://msdn.microsoft.com/en-us/library/system.xml.serialization.soapattributeattribute.aspx
http://msdn.microsoft.com/en-us/library/system.xml.serialization.soapelementattribute.aspx
http://msdn.microsoft.com/en-us/library/system.xml.serialization.soapignoreattribute.aspx
Has these XmlAttribute that start with SOAP anything to do with
the SOAPformatter ?

I would guess that they affect the SOAPFormatter.

But reads the doc and make an experiment.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top