none
how do client side get server side's ArrayList of custom object RRS feed

  • Question

  • can not get ArrayList<BloomClass> in client side

    read operation failed in TcpBinding

    The socket connection was aborted.

    This could be caused by an error processing your message or

    a receive timeout being exceeded by the remote host,

    or an underlying network resource issue.

    Local socket timeout was '00:00:59.9340000'.

    already added

     [DataContract]
        public class BloomClass
        {
            public BloomClass()
            {
                UPDField = false;
            }
            public String code {get; set;}
            public String field {get; set;}
            public int reply {get; set;}
            public String DBTable {get; set;}       
            public String DBField {get; set;}
            public Boolean number {get; set;}
            public Object data  {get; set;}
            public Boolean isnew  {get; set;}
            public String type {get; set;}
            public Boolean UPDField {get; set;}
    
            [DataMember]
            public String proCode
            {
                get 
                {
                    return code;
                }
                set
                {
                    code = value;
                }
            }
            [DataMember]
            public String proField
            {
                get 
                {
                    return field;
                }
                set
                {
                    field = value;
                }
            }
            [DataMember]
            public int proReply
            {
                get 
                {
                    return reply;
                }
                set
                {
                    reply = value;
                }
            }
            [DataMember]
            public String proDBTable
            {
                get 
                {
                    return DBTable;
                }
                set
                {
                    DBTable = value;
                }
            }
            [DataMember]
            public String proDBField
            {
                get 
                {
                    return DBField;
                }
                set
                {
                    DBField = value;
                }
            }
            [DataMember]
            public Boolean proNumber
            {
                get 
                {
                    return number;
                }
                set
                {
                    number = value;
                }
            }
            [DataMember]
            public Object proData
            {
                get 
                {
                    return data;
                }
                set
                {
                    data = value;
                }
            }
            [DataMember]
            public Boolean proUPDFeild
            {
                get 
                {
                    return UPDField;
                }
                set
                {
                    UPDField = value;
                }
            }
            [DataMember]
            public Boolean proisNew
            {
                get 
                {
                    return isnew;
                }
                set
                {
                    isnew = value;
                }
            }
            [DataMember]
            public String proType
            {
                get 
                {
                    return type;
                }
                set
                {
                    type = value;
                }
            }
        }


    client side object[] EquityListObject = test.GetEquityList(); <- error server side

    equityList = biglist.result; public ArrayList GetEquityList() { if (equityList == null) CreateInstanceForNullInstanceCase(); return equityList; } BloomClass bloomObj = new BloomClass(); if (reader["proReply"] != System.DBNull.Value) { bloomObj.proReply = Convert.ToInt32(reader["proReply"].ToString().Trim()); }  BigArrayList result = new BigArrayList(); if (result.result == null) result.result = new ArrayList(); result.result.Add(bloomObj);


     class BigArrayList
        {
            public ArrayList FTPField {get; set;}
            public ArrayList FTPList { get; set; }
            public ArrayList result { get; set; }
        }



    Designer








    Thursday, May 23, 2013 9:40 AM

Answers

All replies

  • Hi,

    Decorate  your Custom Type with KnowType Attribute may solve your problem.

    Thanks,

    N.Satish

    Thursday, May 23, 2013 12:34 PM
  • do not have inheritance, why use KnownType?


    Designer

    Thursday, May 23, 2013 1:38 PM
  • Blow is what a object being sent through WCF should look like. All those public backing variables you have in your object are not needed.

    http://msdn.microsoft.com/en-us/library/bb384054.aspx

    using System;
    using System.Runtime.Serialization;

    namespace BLL.DTO
    {
        [Serializable]
        public class DTOArticle
        {
            [DataMember]
            public int ArticleID { get; set; }
             [DataMember]
            public string Title { get; set; }
             [DataMember]
            public string Body { get; set; }
             [DataMember]
            public int? AuthorID { get; set; }
             [DataMember]
            public Boolean IsUpdate { get; set; }
        }
    }
     If an object has a collection of objects, a List<T>, then the List<T> needs a get/set and DataMember,  and all objects in the List<T> must look like the DTOArticle.
      [DataMember]
     public List<DTOArticle> DTOArticles { get; set; }
     A List<T> is serializable.
     http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
     If anything is not decorated with [DataMember], then it will not be seen on the client-side.

    Thursday, May 23, 2013 2:36 PM
  • solved by send with byte[] 

    Designer

    Friday, May 24, 2013 2:28 AM
  • On 5/23/2013 10:28 PM, zvzzvz wrote:

    solved by send with byte[]

    I think that most WCF developers would not take a byte array approach when sending an object or a collection of objects through WCF.

    Friday, May 24, 2013 2:39 AM