如何增加WCF连接的最大传输长度

刚刚在调试WCF传输Byte[]格式图片时,遇到了WCF默认限制传输不能超过16K的问题。

最开始显示的提示是:

   Bad request , Code:  400

想了一会,觉得是IIS7的配置问题,于是查看了一下默认配置,打开IIS的“失败请求跟踪规则”

image

配置跟踪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服务配置编辑器”

最后成功的情况:

image

此条目发表在C#, 编程分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注