I have a type MyParameter that i pass as a parameter to a wcf service [Serializable] public class MyParameter : IXmlSerializable { public string Name { get; set; } public string Value { get; set; } public string Mytype { get; set; }
#region IXmlSerializable Members
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public void ReadXml(System.Xml.XmlReader reader)
{
XElement e = XElement.Parse(reader.ReadOuterXml());
IEnumerable<XElement> i = e.Elements();
List<XElement> l = new List<XElement>(i);
Name = l[0].Name.ToString();
Value = l[0].Value.ToString();
Mytype = l[0].Attribute("type").Value.ToString();
}
public void WriteXml(System.Xml.XmlWriter writer)
{
writer.WriteStartElement(Name);
writer.WriteAttributeString("xsi:type", Mytype);
writer.WriteValue(Value);
writer.WriteEndElement();
}
#endregion
}
the service contract looks like this: [ServiceContract] public interface IOperation { [OperationContract] void Operation(List list); }
where data defines a data contract [DataContract] public class Data { public string Name { get; set; } public List Parameters{ get; set; } }
when i run the service and test it i get rhe exception in readXml of MyParameter "the prefix xsi is not defined" xsi should define the namespace "http://w3.org/2001/xmlschema-instance"
how do i fix the problem
i am very new to this so a sample code will be very very very helpfull thanks