简体   繁体   中英

List variable is not getting exposed from WCF Service

I am writing a WCF Service which exposed the parameter Pin, gender and addresses. I am consuming the service using WCF Client. In the Client I can see only the simple parameters Pin and gender. I could not see the List<PatronAddress> . I have added [DataContract] and [DataMember] for the patron address class. Can some one let me know how to expose the List from WCF? Thanks.

Code is below.

[DataContract]
public class EnrollPatronInformation
{       
    [DataMember]
    public string Pin { get; set; }

    [DataMember]
    public enums.eGenderType Gender { get; set; }

    [DataMember]
    public List<PatronAddress> Address { get; set; }        
}

[DataContract]
public class PatronAddress
{
    [DataMember]
    public string ContactType { get; set; }

    [DataMember]
    public string Line1 { get; set; }

    [DataMember]
    public string Line2 { get; set; }

    [DataMember]
    public string Country { get; set; }

    [DataMember]
    public string Postal { get; set; }

    [DataMember]
    public string City { get; set; }

    [DataMember]
    public string State { get; set; }
}

Since it is output field use Array for it. You don't need to provide a List to a client. For Arrays it usually works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM