在调用Get in Rest WCF时响应的截断数据。 [英] Truncated data coming in response while calling Get in Rest WCF.

查看:66
本文介绍了在调用Get in Rest WCF时响应的截断数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Restful WCF服务很新,所以请耐心等待。我正在尝试构建一个简单的RESTful WCF服务,该服务返回一个学生列表作为json响应。



响应中约3842条记录显示当我调用相同的方法时浏览器但在实际列表中包含大约9000条记录。



为什么响应被截断?

解决方案

hi one两件事....



尝试在你的web.config上设置maxJsonLength属性:



< pre lang =xml> < configuration >
< system.web.extensions >
< 脚本 >
< webservices >
< jsonserialization maxjsonlength = 此处为大号 / < span class =code-keyword>>
< / webservices >
< / scripting >
< / system.web.extensions >
< / configuration >





或因为它是WCF,您可能需要查看服务行为。尝试设置maxitemsinobjectgraph属性。



 <  行为 >  
< servicebehaviors >
< behavior name = metadataBehavior >
< servicemetadata httpgetenabled = true httpgeturl = / >
< servicedebug includeexceptiondetailinfaults = false / >
< datacontractserializer maxitemsinobjectgraph = 2147483646 / >
< / behavior >
< / servicebehaviors >
< / behavior >





您可以在这里找到其他示例:



http://geekswithblogs.net/mnf/archive/2013/06/02/response-for-rest-method-was-truncated-because-default-maxitemsinobjectgraph-was.aspx [ ^


I am pretty new to Restful WCF services so bear with me. I am trying to build a simple RESTful WCF service that returns a List of Students as json response.

In Response Approx 3842 Records are Showing when i invoke the same method in Browser but in actual List contains approx 9000 records.

Why response is truncated?

解决方案

hi one of two things....

Try setting maxJsonLength property on your web.config:

<configuration>
   <system.web.extensions>
       <scripting>
           <webservices>
               <jsonserialization maxjsonlength="Large number here" />
           </webservices>
       </scripting>
   </system.web.extensions>
</configuration>



or because it is WCF you may want to look at the service behaviours. Try setting the maxitemsinobjectgraph property.

<behaviors>
        <servicebehaviors>
            <behavior name="metadataBehavior">
                <servicemetadata httpgetenabled="true" httpgeturl="" />
                <servicedebug includeexceptiondetailinfaults="false" />
                <datacontractserializer maxitemsinobjectgraph="2147483646" />
            </behavior>
        </servicebehaviors>
    </behaviors>



you may find other examples from here :

http://geekswithblogs.net/mnf/archive/2013/06/02/response-for-rest-method-was-truncated-because-default-maxitemsinobjectgraph-was.aspx[^]


这篇关于在调用Get in Rest WCF时响应的截断数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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