积极答复者
WCF通讯包容量问题

问题
-
开发中遇到一个问题
有一个Ilist,将他直接通过FileStream写到磁盘上,大约100kb
但是将其通过WCF发送到客户端,通过网络防火墙查看,居然变成1.9MB了!!!
原先我用的是人工二进制序列化的方式再basichttpbinding上传输的,估算能容量能压缩到接近1/10,这次用了netHttpBinding的Binary反而大了那么多?
从MS的官方文档上看netHttpBinding的好处多多,还能换成HTTPS的,请问一下如果我追求最小的通讯量(客户那边网络实在是差),请问该如何配置啊?
PS:在应用时打开了“重新使用引用的程序集类型”。
两边配置如下
服务端binding
<netHttpBinding>
<binding name="NewBindingTest2" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" messageEncoding="Binary" />
</netHttpBinding>客户端binding
<netHttpBinding>
<binding name="netHttpBindingTest" closeTimeout="00:10:00" openTimeout="00:10:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" messageEncoding="Binary">
<webSocketSettings transportUsage="WhenDuplex" />
</binding>
</netHttpBinding>
答案
-
嗨,
我建议你试试customBinding结合binaryMessageEncoding,compressionFormat。
<customBinding> <binding name="BinaryCompressionBinding"> <binaryMessageEncoding compressionFormat ="GZip"/> <tcpTransport></tcpTransport> </binding> </customBinding>
另外,你能把你定义的实体类分享给我们看下么?
Best Regards,Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已编辑 Edward8520Microsoft contingent staff, Moderator 2016年12月8日 6:28
- 已标记为答案 asuras 2017年2月27日 8:55
全部回复
-
嗨,
我建议你试试customBinding结合binaryMessageEncoding,compressionFormat。
<customBinding> <binding name="BinaryCompressionBinding"> <binaryMessageEncoding compressionFormat ="GZip"/> <tcpTransport></tcpTransport> </binding> </customBinding>
另外,你能把你定义的实体类分享给我们看下么?
Best Regards,Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已编辑 Edward8520Microsoft contingent staff, Moderator 2016年12月8日 6:28
- 已标记为答案 asuras 2017年2月27日 8:55
-
namespace HJLite.Entity.Model
{
[Serializable]
[DataContract]
public class Sys_DictModel : BaseModel
{
[DataMember]
public String Id
{
get;
set;
}
[DataMember]
public String RootKey
{
get;
set;
}
[DataMember]
public String ParentKey
{
get;
set;
}大概其就是这样,有打标签,没有申明私有变量,所有的int和datetime都改成了int?和datetime?,没有什么太特殊的类型。
所有的实体基本上都是符合这样的规则的