通过Web服务器调用时,WCF响应被截断

时间:2014-04-01 19:00:10

标签: c# wcf

有一个Web服务(我无法控制)返回一个大的响应。在简单的控制台应用程序中,对服务的调用将返回预期的数据。但是,当我在Web应用程序中执行相同操作时,会丢失一些数据。

如果我将响应序列化并将其写入文件,则一个文件为215mb,另一个文件为117mb(它们的大小应相同)。

Web服务错误发生在我的本地机器上和生产Web服务器上。

没有错误被抛出。我已经运行了WCF跟踪,并且没有显示任何错误或警告。事件日志中没有记录任何内容。

< system.serviceModel>配置部分在两个应用程序之间完全相同。

 <system.serviceModel>
        <bindings>
            <wsHttpBinding>
              <binding name="WSHttpBinding_Service" maxReceivedMessageSize="2147483647" />
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://myService/Service.svc" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_Service" contract="MyService.Service"
                name="WSHttpBinding_Service">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
</system.serviceModel>

1 个答案:

答案 0 :(得分:1)

有几种可能性:

  • 如果数据被截断,则会出现格式错误的xml,这会导致异常。
  • 如果Web服务器没有使用正确的配置文件,并且它不允许响应的大小,则会出现异常。

在上述两种情况下,您都无法序列化结果。

所以你得到了一个好的xml,但它的大小不同。然后有两种可能性:

  • 影响尺寸的编码差异
  • 请求参数的差异,影响返回的内容
相关问题