views:

168

answers:

2

Hello Friends,

i have been tasked to write a new web service with returns list of Addresses

to do so i have created a class as bellow

 [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 appliction. the visual studio code generator returns AddressData[] and discards ErrorCode, ErrorMessage props

can you please guid me through if i am missing some thing

i am using asp.net 2.0 for client and service

thanks

A: 

Unfortunately, you can't do this. You will have to create a class that contains the list and the two properties, and serialize that.

John Saunders
+1  A: 

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.

Matt Howells