Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey to all,

I am submitting class obj to web service with two images byte array that is fine. But when i want to get same class object with images in form of byte array it service raise exception of (The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.)

i have tried to increase MaxReceivedMessageSize = "2147483647" but still facing this issue.
Posted

1 solution

1. Note that when you are sending an object (created from a class) and that object/class has public properties that are referring other objects, an entire graph of objects will be sent automatically via WCF.

If is this case in your case, you should create and use a class dedicated for transferring the data between WCF service and its client, and this class to have only the needed properties/data that must be transferred.

2. If is not the above case you should increase the values of the next WCF parameters, but note that the changes must be done on both sides (config files of WCF service and WCF client): maxReceivedMessageSize, maxBufferSize, maxBufferPoolSize
 
Share this answer
 
Comments
bilal _hassan 10-Dec-14 4:42am    
Thanks Raul Iloc

Actually there is no problem when class object is returned without Byte[] of Images but as i try to send Byte[] in any form like(Base64, compressed with GZipStream, Xml String, in Dictionay<t>) it raised exception.

Secondly i want a permanent solution for this as i am retrieving persons detail on search bases so it can be one to many records returned.

and one unbelievable thing is that: While sending same object with two imges byte arrays it do not create issue. thats strange for me.
Raul Iloc 10-Dec-14 6:50am    
You can try then two solutions:
1)If the file are big, the better way is to create a method that return as "out" param (supposing that the return value should be an error code) and this method to return the data array of each individual file. This is the way I am using in my projects also.
2)To increase the WCF parameters as I suggested in my 2nd point of my solution above. Note that you will need maybe to increase other WCF parameters that control the size of an array for example like: maxArrayLength="2147483647" !
bilal _hassan 10-Dec-14 23:27pm    
Out param is also not working. I have tried this. It raise same issue.
i have set maxArrayLength="2147483647" and all other properties on this same value. plz have a look:

binding
maxbuffersize="2147483647" maxbufferpoolsize="2147483647" maxreceivedmessagesize="2147483647"
readerquotas
maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647"
readerquotas
binding

still no good news. :(
Raul Iloc 11-Dec-14 1:14am    
1.Try to set only the next params, and let others to their default values:
i)In Binding: maxBufferPoolSize="21474836470", maxBufferSize="2147483647", maxReceivedMessageSize="2147483647"
ii)readerQuotas: maxArrayLength="2147483647", maxBytesPerRead="2147483647".

2.You must have the same values for this WCF settings in both sides: WCF service and also WCF client, these means also in the application that is hosting the WCF service (app.config) and the Web.config for a web application, OR app.config for a Windows Forms or WPF application in the case of the WCF client. Did you do in this way?

bilal _hassan 12-Dec-14 6:20am    
Thanks alot Raul Iloc....
Setting of (maxReceivedMessageSize="2147483647") solved my issue... thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900