WCF方法被调用两次 [英] WCF method called twice

查看:118
本文介绍了WCF方法被调用两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务,正在将数据返回到桌面应用程序.我遇到的问题是,当Web服务返回少量数据时,一切正常,但是当数据量较大时,它将引发以下异常:

I have a web service which is returning data to the desktop application. The problem I am having is, when the web service returns small volume of data everything works fine but when the volume of data is large it throws the following exception:

System.Net.WebException:基础连接已关闭:接收时发生意外错误.

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.

当我调试Web服务时,我看到此特定方法被调用了两次.第一次执行return语句没有任何反应,但是第二次执行返回语句时,台式机应用程序会抛出上述异常.

And when I am debugging the web service, I see that this particular method is called twice. It executes the return statement 1st time nothing happens, but when it does execute it for the second time the above mentioned exception is thrown in the desktop app.

我在stackoverflow上找到了类似的帖子,但是它们并没有解决我的问题.有人可以告诉我这里发生了什么吗?

I found similar posts before on stackoverflow but they did not solve my problem. Can anybody please tell me what's going on in here?

谢谢!

推荐答案

这可能是因为消息的大小大于默认消息的大小.您可以尝试增加此值在端点的配置中.您还可以查看这篇文章.

It could be because the size of the message is greater than the default message size. You might try increasing the this value in the configuration of the endpoint. You could also take a look at this post.

更新:

为进一步诊断问题,我建议您通过将以下内容放入配置文件来激活服务上的跟踪记录:

To further diagnose the problem I would suggest you activating the trace on the service by putting the following in the config file:

<system.diagnostics>
    <trace autoflush="true">
    </trace>
    <sources>
        <source name="System.ServiceModel"
                switchValue="Information, ActivityTracing"
                propagateActivity="true">
            <listeners>
                <add name="sdt"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="WcfDetailTrace.e2e" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>

这将生成WcfDetailTrace.e2e跟踪文件,您可以使用服务打开跟踪查看器工具,它将为您提供有关调用和错误消息的广泛信息.

This will generate the WcfDetailTrace.e2e trace file which you could open with the Service Trace Viewer Tool which will provide you with extensive information about the call and the error message.

这篇关于WCF方法被调用两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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