views:

377

answers:

3

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?

+1  A: 

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 lenght

  1. Have you made your class serialize able.? If not then make it like this

[DataContract]

public Class MyEntry

{

  [DataMember]

  public string Name {get; set;}

  [DataMember]

  public long Age {get; set;}
}
Johnny
I'm using wsHttpBinding and I have decorated it with DC
Sandeep
then set set the maxBufferPoolSize="As u want" maxReceivedMessageSize="As u want" and other stuffs like maxStringContentLength="As u want" maxArrayLength="As u want" maxBytesPerRead="As u want" maxNameTableCharCount="As u want"
Johnny
A: 

There's MaxReceivedMessageSize, MaxStringContentLength and MaxBufferSize.

Check the link

http://geekswithblogs.net/niemguy/archive/2007/12/11/wcf-maxstringcontentlength-maxbuffersize-and-maxreceivedmessagesize.aspx

Read related question on how to increase size

http://stackoverflow.com/questions/369132/wcf-max-message-size

http://stackoverflow.com/questions/330034/silverlight-wcf-max-message-size

EDIT Check also Service Reference's configuration. You should set Dictionary collection type to Dictionary.

Good Luck!

hgulyan
A: 

You unfortunately have a bigger problem and that's that you can't serialize an IDictionary.

You're probably going to have to create an array or similar of a serializable custom key-value type.

Doobi