刚刚在调试WCF传输Byte[]格式图片时,遇到了WCF默认限制传输不能超过16K的问题。
最开始显示的提示是:
Bad request , Code: 400
想了一会,觉得是IIS7的配置问题,于是查看了一下默认配置,打开IIS的“失败请求跟踪规则”
配置跟踪400错误,之后再运行,显示错误:
“The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation ‘XXX’. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 39987.”
现在看到错误了,可以去Google一下,查看到具体信息,需要调整:
这篇文章写的很详细:How to Increase the MaxArrayLength in a WCF Component
注意的情况有:1. 分别更新客服端和服务端的.config文件 2. 推荐使用工具里的“WCF服务配置编辑器”
最后成功的情况: