Search code examples
c#dictionarywcf

Passing a Dictionary to WCF service


I need to pass a Dictionary (with max 20,000 entries) to a WCF service. Can I pass it all by once?

void SubmitDictionary(Dictionary<string, MyEntry> val);

where MyEntry is :

class MyEntry
{
    string Name;
    long Age;
}

Is there a configuration for size of the value passed? Or can we pass as large data as this?


Solution

  • Two things I need to know.

    1. What type of binding r u using ? Like BasicHttpBinding or wsHttpBinding. If you are using wsHttpBinding you don't need to worry about it's length

    2. Have you made your class serializeable? If not then make it like this:

        [DataContract]
        public Class MyEntry
        {
              [DataMember]
              public string Name {get; set;}
    
              [DataMember]
              public long Age {get; set;}
        }