今日。对代码进行单元測试时。发现方法GetAllSupplyTypes报例如以下错误:

[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

经过对照。唯一的差异是该方法返回的数据对象是一个继承于还有一个集合对象的对象,代码例如以下:

/// <summary>
/// SupplyType的值的集合
/// </summary>
[DataContract]
public class SupplyTypeResults : List<SupplyType>
{
/// <summary>
/// 构造函数
/// </summary>
public SupplyTypeResults()
{
this.Add(new SupplyType
{
SupplyTypeId = 2,
SupplyTypeName = "其它投放方式"
}); this.Add(new SupplyType
{
SupplyTypeId = 1,
SupplyTypeName = "平台自己主动投放"
}); this.Add(new SupplyType
{
SupplyTypeId = 0,
SupplyTypeName = "客户主动领取"
});
}
}

当中,SupplyType定义例如以下:

/// <summary>
/// 优惠券发行方式
/// </summary>
[DataContract]
public class SupplyType
{
/// <summary>
/// 发行方式Id
/// </summary>
[DataMember(Name = "supplyTypeId")]
public int SupplyTypeId { get; set; } /// <summary>
/// 发行方式名称
/// </summary>
[DataMember(Name = "supplyTypeName")]
public string SupplyTypeName { get; set; }
}

自以为继承与一个WCF能正常序列化的对象,并且在SupplyTypeResults上也加了DataContract应该没有问题,可是就是报错。

后来不再使用SupplyTypeResults类,在代码中直接使用List<SupplyType>。问题所有解决。

之后。有发现还有一个方法也会产生该问题。可是,该方法不属于此原因范畴。经过一阵排查,发现返回类中有个日期属性没有赋值,导致了该错误的抛出。

经过上述两事件总结能够得出,对于不论什么在序列化过程中可能出错的情况。都会导致server返回0字节数据而报此错误。

WCF问题集锦:ReadResponse failed: The server did not return a complete response for this request.的更多相关文章

  1. [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

    待解决 [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. ...

  2. file_get_contents HTTP request failed! Internal Server Error

    使用file_get_contents报错 Severity: WarningMessage: file_get_contents(http://geetest.com:8000/select?gid ...

  3. OPENTSDB: Request failed: Internal Server Error net.opentsdb.core.IllegalDataException

    今天Opentsdb补传历史数据的时候,出现了如下的错误: Request failed: Internal Server Error net.opentsdb.core.IllegalDataExc ...

  4. Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html"

    2015-11-16 10:39:17.235 PullDemo[338:60b] Application windows are expected to have a root view contr ...

  5. Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptabl

    在使用AFNetworking 2.0  的时候本来一切很顺畅,但是中途遇到几个比较坑的地方 这里分享一下爬坑经历,忘读者不能速爬坑! 在发送请求后,NSURLSessionDataTask一直报错 ...

  6. svn Server sent unexpected return value (403 Forbidden) in response to CHECKOUT

    今天,提交資料到公司svn服務器,但是一直提示 Server sent unexpected return value (403 Forbidden) in response to CHECKOUT ...

  7. FAIL - Deploy Upload Failed, Exception: [org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (112503036) exceeds the configured

    Message:  FAIL - Deploy Upload Failed, Exception: [org.apache.tomcat.util.http.fileupload.FileUpload ...

  8. Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public xxxxxxxx.

    最近在使用 springBoot开发的时候, 使用PostMan访问接口,  返回一个 404 ,  后台报一个 warn : Failed to read HTTP message: org.spr ...

  9. recv() failed (104: Connection reset by peer) while reading response header from upstream

    2017年12月1日10:18:34 情景描述: 浏览器执行了一会儿, 报500错误 运行环境:  nginx + php-fpm nginx日志:  recv() failed (104: Conn ...

随机推荐

  1. CAD使用SetxDataDouble写数据(网页版)

    主要用到函数说明: MxDrawEntity::SetxDataDouble 写一个Double扩展数据,详细说明如下: 参数 说明 [in] BSTR val 字符串值 szAppName 扩展数据 ...

  2. 观察者模式在Foundation框架通知中的应用

    GitHub传送门 1.何为观察者模式? 观察者设计模式定义了对象间的一种一对多的依赖关系,以便一个对象的状态发生变化时,所有依赖于它的对象都得到通知并自动刷新. 举个简单的例子:你和你的舍友都订阅了 ...

  3. 11Java Server Pages 动作

    Java Server Pages 动作 JSP标准动作 分类 JSP标准动作 存取JavaBean相关 <jsp:useBean> <jsp:setProperty> < ...

  4. sql常用手法(二)

    drop,TRUNCATE和delete的区别 1.DROP删表,表结构将删了,当然数据也不存在了2.TRUNCATE和DELETE删数据,表结构还在3.DELETE可以带条件删除,TRUNCATE是 ...

  5. A useful logger function in C project.

    #cat log.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include < ...

  6. Extjs选中多行Grid提交

    要实现的效果如图:可以选择多行grid然后提交给后台 1,Extjs中grid如何可以选择多行? 定义一个grid,将色了Type设置为多选即可 selType: 'checkboxmodel', 2 ...

  7. <MyBatis>入门一 HelloWorld

    1.HelloWorld 导入依赖 <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --> <dependen ...

  8. buf.writeInt16BE()函数详解

    buf.writeInt16BE(value, offset[, noAssert]) buf.writeInt16LE(value, offset[, noAssert]) value {Numbe ...

  9. dock helloworld

    Docker Hello World Docker 允许你在容器内运行应用程序, 使用 docker run 命令来在容器内运行一个应用程序. 输出Hello world runoob@runoob: ...

  10. dp专题备忘录

    hdu 1024:基础dp题 hdu 1029:主元素问题,很快的解法,计数器 hdu 1069:LIS hdu 1074:数位dp,数位dp基础 hdu 1257:简单LIS,要仔细分析为什么是求最 ...