Json Web Service的最大内容长度? [英] Json web service max content length?

查看:94
本文介绍了Json Web Service的最大内容长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在构建json格式的Asp.net WCF Web服务.现在,我想真正测试发送大量数据时它的工作方式.我的http帖子的Content-Length是65595.直接尝试连接时,我收到了错误消息"HTTP/1.1 400 Bad Request".似乎根本没有尝试.

I have been building a Asp.net WCF web service with json format. Now I wanted to really test how its working when sending lots of data. The Content-Length of my http post is 65595. Directly when trying to connect I got error "HTTP/1.1 400 Bad Request" back. It seems like it's not even trying.

我知道我正在发送有效的json,并且我要发送的是一个包含约1000个项目的数组,每个项目的json看起来像这样: {"oid":0,"am":1,"me":2,"ofooid":0,"fooid":1104,"sync":1,"type":1,"id":1443,"date:" 2009-09-24}

I know I'm sending valid json and what I'm sending is an array with about 1000 items, and the json for each item looks like this: {"oid":0,"am":1,"me":2,"ofooid":0,"fooid":1104,"sync":1,"type":1,"id":1443,"date":"2009-09-24"}

如果我只是删除数组中的一项,那么总内容长度为65484,则可以正常工作.因此,似乎这是某个地方的魔术极限.是Asp.net限制了请求的大小吗?在这种情况下,如何更改最大大小?

If I just delete one of the items in the array so the total content-length is 65484 it works perfect. So it seems like it's a magic limit around there somewhere. Is it Asp.net that limit the size of the request, and how can I change the max size if that's the case?

我的Web.Config文件看起来像,我想应该在此处某个位置设置最大值,但是我不知道在哪里:

My Web.Config file looks like, and I think I should set the maximum value here somewhere but I just don't know where:

<system.serviceModel>
    <behaviors>
       <endpointBehaviors>
           <behavior name="ServiceAspNetAjaxBehavior">
                <enableWebScript  />
           </behavior>
       </endpointBehaviors>
       <serviceBehaviors>
           <behavior name="ServiceBehavior">
                <serviceDebug includeExceptionDetailInFaults="true" />
           </behavior>
       </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="ServiceBehavior" name="Service">
            <endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="Service" />
        </service>
    </services>
</system.serviceModel>

推荐答案

您需要在WebHttpBinding的绑定配置中增加maxReceivedMessageSize.默认值为65536.有关所有以下内容,请参见 WebHttpBinding配置文档.信息.

You need to increase the maxReceivedMessageSize in the binding configuration for WebHttpBinding. The default is 65536. See the WebHttpBinding configuration documentation for all of the information.

还请注意,您可能需要通过httpRuntime配置来增加ASP.NET maxRequestLength.默认值为4 MB,但您可能需要增加:

Also note that you may need to increase the ASP.NET maxRequestLength via the httpRuntime configuration. The default is 4 MB but you may need to increase:

<httpRuntime maxRequestLength="10000" />

这篇关于Json Web Service的最大内容长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆