Hello.
I'm trying to serialize an inherited Class by a Webservice. Here ist a
Code-Snippet of the Classes I try to serialize:
// Base-Class
public class Test
{
private string _Argument1;
public string Argument1
{
get { return _Argument1; }
set { _Argument1 = value; }
}
}
// Inherited Class
public class TestEx : Test
{
private string _Argument2;
public string Argument2
{
get { return _Argument2; }
set { _Argument2 = value; }
}
}
Now I try to return the Base-Class by a WebService:
[WebMethod]
[XmlInclude(typeof(Test))]
public Test ReturnTest()
{
TestEx testEx = new TestEx();
testEx.Argument1 = "Arg1";
testEx.Argument2 = "Arg2";
return (Test) testEx;
}
But this code throws an Exception: The Type inheritanceText.TextEx was
expected.
If I change the XMLInclude-Attribute to [XmlInclude(typeof(TestEx))], no
Exception is thrown, but the Webservice returns TestEx-Object. But I want the
Base-Class returned ...
What am I doing wrong?
Thanks in advance,
Björn Schwemmer
--
iucon GmbH
Software Developement
http://www.iucon.de