So here's the challenge...
How can a collection (System.Collections.Generic.IList) of some custom type
be serialized in a web service using .NET 2.0?
Below are the class and the web methods in question. The interesting thing
is that at each step of the way, DAL & Biz, the someType class is decorated
with the Serializable attribute. And the someTypes collection in the web
method is correctly populated with the data after the call to
someType.GetList(). But the only thing that is returned from the web method
call is:
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOf_someType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<_someType />
</ArrayOf_someType>
I've worked through a variety of options but nothing seems to be a feasible
solution. Someone please enlighten me!
Thanks...
Here's the _someType class:
[Serializable]
public sealed class _someType
{
private readonly String _key;
private readonly String _desc;
private readonly Boolean _isActive;
public _someType(string key, string desc, bool isActive)
{
this._key = key;
this._desc = desc;
this._isActive = isActive;
}
public _someType()
{
//nothing...needed to allow to be serialized from
//service facade
}
[System.Xml.Serialization.XmlElementAttribute()]
public string Key
{
get
{
return _key;
}
}
[System.Xml.Serialization.XmlElementAttribute()]
public string Desc
{
get
{
return _desc;
}
}
[System.Xml.Serialization.XmlElementAttribute()]
public bool IsActive
{
get
{
return _isActive;
}
}
}
And here's the web method:
[WebMethod]
public List<_someType> GetAll()
{
//instantiate an instance of SomeType (at the middle tier)
SomeType someType = new SomeType();
//return a collection of _someType
List<_someType> someTypes = someType.GetList();
return someTypes;
}