WCF可以返回一个列表时返回单个对象得很好,但失败 [英] WCF can return single object just fine but fails when returning a list

查看:86
本文介绍了WCF可以返回一个列表时返回单个对象得很好,但失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过列表,没有任何问题,当我尝试发送此特定对象(名单)我得到的,有点超时错误发送的各种其他对象在我的WCF服务不过。

I've sent various other objects over my WCF service through lists without any issues however when I try to send this specific object (in a list) I get, sort of a timeout error.

跟踪标识符是: TraceIdentifier <一href="http://msdn.microsoft.com/da-DK/library/System.ServiceModel.Diagnostics.TraceTruncatedQuotaExceeded.aspx" rel="nofollow">http://msdn.microsoft.com/da-DK/library/System.ServiceModel.Diagnostics.TraceTruncatedQuotaExceeded.aspx

The trace identifier is: TraceIdentifier http://msdn.microsoft.com/da-DK/library/System.ServiceModel.Diagnostics.TraceTruncatedQuotaExceeded.aspx

奇怪的是:我得到的仅仅返回对象(不在列表)另一种方法,并能正常工作

The strange thing is: I got another method that returns the object exclusively (not in a list) and it works fine.

此外,调试时,我发现,该方法(服务端)返回列表就好了但是它的,显然无法接受它的客户端。

Furthermore when debugging I've found out that the method (on the service side) returns the list just fine however it's the client that apparently fails receiving it.

下面是调用该服务的方法(它无法上线,宣布转速):

Here's the method that calls the service (it fails on the line declaring "revs"):

public void GetReviewsInModule()
        {
            using (var db = new RentItServiceClient())
            {
                var revs = db.GetReviewsInModule(1);
            }
        }

下面是实际返回objectas列表中的方法(调试它,它返回它精):

Here's the method that actually returns the objectas a list (debugged it and it returns it fine):

public List<ReviewModule> GetReviewsInModule(int id)
    {
        using (Context con = new Context())
        {
            con.Configuration.ProxyCreationEnabled = false;
            var mod = con.Modules.Find(id);
            if (mod == null)
                throw new WebServiceValidationException("Object does not exist");
            List<ReviewModule> revs = con.ModuleReviews.Include("User").Where(r => r.Module.Id == id).ToList();
            return revs;
        }
    }

此外,在列表中的对象几乎没有任何尺寸,所以请不要告诉我了发送/接收限制/超时。

Also, the object in the list are hardly of any size so please don't tell me to up the sending/receiving limits/timeouts.

推荐答案

这真的取决于很多因素都在结果列表中,也不仅在单个元件的尺寸。有一些配置元素,你可以玩:

It really depends on how many elements are in the result list, too, not only on the sizes of the individual elements. There are some configuration elements you can play with:

maxReceivedMessageSize
maxBufferSize
maxBufferPoolSize
maxArrayLength
maxStringContentLength

另一解决方案是切换到流的WCF服务。请注意,您不能混用流和缓冲操作 - 我有时竟创建两个WCF服务,一个是流媒体业务,一个用于缓冲的操作

Another solution would be to switch to streamed WCF services. Please note that you can not mix streamed and buffered operations - I sometimes actually create two WCF services, one for streamed operations and one for buffered operations.

这篇关于WCF可以返回一个列表时返回单个对象得很好,但失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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