I've started developing a new web service in VS2005. There is only one method:
[WebMethod]
[XmlInclude(typeof(Person))]
public PersonAction GetAction()
{
PersonAction action = new PersonAction();
return action;
}
where PersonAction
class contains a field with a reference to a Person
class
[Serializable]
public class PersonAction
{
private string actionName = "XAction";
private Person person1;
private Person person2;
public PersonAction()
{
this.person = new Person();
this.person.Name = "P1";
}
public string Name
{
get
{
return this.actionName;
}
}
[XmlElement(Type = typeof(Person))]
public Person Person1
{
get
{
return this.person1;
}
}
}
I've built it, run it... but wsdl it always contains an empty tag for PersonAction
... no definition for the embedded types is available, so I get always null on the client side.
XmlElement
, XmlInclude
, [Serializable]
apparently have no effect...
I am sure I miss something.
For sure somebody faced this problem in the past and knows the solution. I would really appreciate any piece of code for VS2005 (.NET 2.0) that would help.
Thank you