0

I'm coding a web service where I have these class

public class Result 
{
   public string Arc {get; set;} 
   public List<Parent> Parents {ger; set;}
}

public class abstract Parent 
{
}

public class ChildOne : Parent 
{ 
    public string Name {get; set;}
    public string Code {get; set;}
}
public class ChildTwo : Parent 
{ 
    public string Codebar {get; set;}
    public string Street {get; set;}
}

I have a function :

public Result MyFunction()
{
     Result result = new Result(); 

     ChildOne child1 = new ChildOne();
     result.Parents.Addchild1);     

     ChildTwo child2 = new ChildTwo();
     result.Parents.Add(child2);  

     return result;  
}

When I debug every thing is fine I see that my object ChildOne and ChildTwo was created and added to the list Parents. My problem is when I try to test My Web service using souapUi I get these errors

Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write6_Element(String n, String ns, Element o, Boolean isNullable, Boolean needType) Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write7_Rop(String n, String ns, Rop o, Boolean isNullable, Boolean needType) Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write13_Rop(Object o) Microsoft.Xml.Serialization.GeneratedAssembly.RopSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer) System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)

Can someone help me please ?

  • Possible duplicate of [How to make a serializable class that contains an instance of one class from a set of classes](https://stackoverflow.com/questions/14326832/how-to-make-a-serializable-class-that-contains-an-instance-of-one-class-from-a-s) – Pavel Pája Halbich Jul 24 '17 at 13:54
  • I solved a problem by adding [XmlInclude(typeof(ChildOne))] [XmlInclude(typeof(ChildTwo))] public class abstract Parent { } – kerrache massipssa Jul 24 '17 at 14:43

0 Answers0