WCF REST service 400 Bad Request

WCF REST service 返回是400 错误。

默认超过65K传输时产生异常。解决Webcofig中webHttpEndpoint配置maxReceivedMessageSize 等。

<!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" maxBufferSize="2147483647"  maxReceivedMessageSize="2147483647" maxBufferPoolSize="0" helpEnabled="true" automaticFormatSelectionEnabled="true" faultExceptionEnabled="true">
          <readerQuotas maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"  maxDepth ="2147483647" />
        </standardEndpoint>

以上放置在webHttpEndpoint节点下。

VS2010中有配置编辑器,可以用来编辑WCF中的webconfig

参考文章:

http://stackoverflow.com/questions/6599355/wcf-rest-service-400-bad-request

http://msdn.microsoft.com/zh-cn/ff657121

此条目发表在学习笔记分类目录,贴了, , , 标签。将固定链接加入收藏夹。

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.