zoukankan      html  css  js  c++  java
  • 当调用wcf, 小心返回值包含enum越界的错误。

    前段时间处理过一个调用wcf的exception(那是一个非常奇怪的exception, 经过line by line的调试,exception是在调用出wcf operation的时候抛的):

    System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:59.9730000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:59.9730000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

     

    今天又遇到这个exception,而且都是在刚出wcf operation 调用的时候抛得,但郁闷的是我们竟然忘了上次是什么原因造成,怎么解决的了。

    今天只能由重新调查,第一感觉可能是server和client的接口定义不一致的,但通过调查,包括使用wcftestclient测试,发现感觉是错误的。

    但错误是怎么导致的?通过comment一些代码测试后,大家终于搞清楚了原因,最让我们感到脸红的是这个错误跟前段时间处理的exception完全是同一个问题导致的,竟然我们都忘记了原因。

    所以再此记录下来:

    这个原因:在返回client的结构中有一个enum的属性越界了,那是因为server代码没有检查enum是否越界,直接强制转换成enum. 当从server返回client一个越界的enum就产生了那个exception.

    汗。

  • 相关阅读:
    Redis教程_2
    Redis教程_1
    机器学习概念_2
    机器学习概念_1
    [极客大挑战 2019]LoveSQL
    [极客大挑战 2019]EasySQL
    [SUCTF 2019]EasySQL
    [强网杯 2019]随便注
    [HCTF 2018] WarmUp
    php代码函数笔记
  • 原文地址:https://www.cnblogs.com/lxg226/p/1837048.html
Copyright © 2011-2022 走看看