WCF ignore my message
I'm using WCF configured with netMsmqBinding, and I needed to send a message containing binary data (specifically for image file). When I tried to send a dummy message (i.e. new byte[] { 0, 1, 2, 3 } ), it worked, but when I tried to send a real image file (around 90 kb), it didn't work at all. When I checked the queue (MSMQ), it turns out empty, so I suspect my WCF ServiceHost already consumed the message, but still, why the message was ignored?
After doing *stupid* experiment by sending various sized binary message, turns out that it will ignore fields (in my case array of byte) sized over 16384 bytes (that is, 2^14). Please note that I was using the default configuration. But after doing experiments on various configuration, I found out that in the binding element, you can configure readerQuotas element.
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
In this case, I'm particularly interested in maxArrayLength attribute. Note that the size specified here doesn't relate to the overall message size, but only the individual field of the message. Turns out that the it refused to serialized any field sized over the specified size resulting in WCF skips the serialization of that particular message (bottom line, it ignores the message). So, what I did here is just specify the size, and it worked automagically.
For more information, check Security Considerations for Data
Best Regards,
Ferry Mulyono