I have been tasked to write a new web service with returns list of Addresses.
To do so I have created a class as follows:
[Serializable]
public class AddressDataCollection : List<AddressData>
{
private long m_ErrorCode;
private string m_ErrorMessage;
public long ErrorCode
{
get
{
return m_ErrorCode;
}
set
{
m_ErrorCode = value;
}
}
public string ErrorMessage
{
get
{
return m_ErrorMessage;
}
set
{
m_ErrorMessage = value;
}
}
}
I have a web service function with returns this object.
[WebMethod]
public AddressDataCollection FastFindLookup(string strAddress, int MaxWaitTimeInMilliSeconds)
{
}
However when I try to consume this object in my client application, the visual studio code generator returns AddressData[] and discards ErrorCode, ErrorMessage props.
I am using asp.net 2.0 for client and service.
Am I missing something?
Best Answer
You can either have the list of AddressData as a property, or implement IXmlSerializable and roll your own serialization. Probably the first way is easiest.