C# WCF WinCE 解决方案 错误提示之:已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性...

C# WCF WinCE 解决方案 错误提示之:已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性

网上的解决方案:

 

出现这种错误,先去修改服务器端和客户端的MaxReceivedMessageSize值,如果还报错那么查看你的代码调用了是不是new了一个新的BasicHttpBinding对象,如果是new了新的那么你的webconfig根本就没有被调用,在new的时候要将 <binding name="DataSyncService" 中的name值作为参数传进去,或者是在代码里重新设置MaxReceivedMessageSize值

第一种

DataSyncServiceClient service = new DataSyncServiceClient(new BasicHttpBinding("DataSyncService"), new EndpointAddress(new Uri(con)));

第二种

DataSyncServiceClient service = new DataSyncServiceClient(new BasicHttpBinding(), new EndpointAddress(new Uri(con)));

(service.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
(service.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = int.MaxValue;
(service.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;

我自己项目中的问题:

                //SMC.Binding binding = U8ServiceClient.CreateDefaultBinding();
                //string remoteAddress = U8ServiceClient.EndpointAddress.Uri.ToString();
                //EndpointAddress endpoint = new EndpointAddress(remoteAddress);
                //U8Client = new U8ServiceClient(binding, endpoint);
                //SessionID = U8Client.StartSession();

我们之前是用上面的这个方法来的:即使我在服务器端设置了:

 maxReceivedMessageSize="2147483647"

<dataContractSerializer maxItemsInObjectGraph="2147483647" />

也还是不起作用。

 

<?xml version="1.0"?>
<configuration><system.web><compilation debug="true" targetFramework="4.0"><assemblies><add assembly="Interop.U8Login, Version=1.14.0.0, Culture=neutral, PublicKeyToken=79A4E7AD54EEABCA"/></assemblies></compilation><customErrors mode="Off"/></system.web><appSettings><add key="defaultConnection" value="sqlCon"/><add key="DALAssemblyName" value="HZYA.DALSQLServer"/><add key="DALFactoryType" value="HZYA.DALSQLServer.DALMSSqlFactory"/><add key="SessionTimeOut" value="00:30:00"/></appSettings><connectionStrings><!--<add name="sqlCon" connectionString="Data Source=CQY-PC\SQLEXPRESS2005;Initial Catalog=UFDATA_001_2010;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="System" connectionString="Data Source=CQY-PC\SQLEXPRESS2005;Initial Catalog=UFSysTem;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="Barcode" connectionString="Data Source=CQY-PC\SQLEXPRESS2005;Initial Catalog=Barcode;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/>--><add name="sqlCon" connectionString="Data Source=wuyf\sql2005;Initial Catalog=UFDATA_001_2012;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="System" connectionString="Data Source=wuyf\sql2005;Initial Catalog=UFSysTem;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="Barcode" connectionString="Data Source=wuyf\sql2005;Initial Catalog=Barcode;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/></connectionStrings><system.serviceModel><services><service name="CommonService" behaviorConfiguration="ServiceBehavior"><endpoint address="" binding="wsHttpBinding" contract="ICommonService" bindingConfiguration="LargeSizeWsHttpBinding"/><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="ICommonService" bindingConfiguration="LargeSizeBasicHttpBinding"/></service><service name="BarcodeService" behaviorConfiguration="ServiceBehavior"><endpoint address="" binding="wsHttpBinding" contract="IBarcodeService"/><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IBarcodeService"/></service><service name="PrintService" behaviorConfiguration="ServiceBehavior"><endpoint address="" binding="wsHttpBinding" contract="IPrintService"/><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IPrintService"/></service><service name="LoginService" behaviorConfiguration="ServiceBehavior" ><!--<endpoint address="" binding="wsHttpBinding" contract="ILoginService" bindingConfiguration="NoneSecurity" /><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>--><endpoint address="basic" binding="basicHttpBinding" contract="ILoginService"/></service><service name="U8Service" behaviorConfiguration="ServiceBehavior" ><endpoint address="" binding="wsHttpBinding" contract="IU8Service" /><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IU8Service"/></service><!--<service name="U8Service" behaviorConfiguration="ServiceBehavior" ><endpoint address="" binding="wsHttpBinding" contract="ILoginService" bindingConfiguration="NoneSecurity" /><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IU8Service"/></service>--></services><bindings><basicHttpBinding><binding name="LargeSizeBasicHttpBinding" maxBufferPoolSize="2147483647" receiveTimeout="00:00:10" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"><readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/></binding></basicHttpBinding><wsHttpBinding><binding name="LargeSizeWsHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"><readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/></binding><binding name="NoneSecurity" receiveTimeout="00:00:50" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false"><readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/><reliableSession enabled="true"/><security mode="None"><message establishSecurityContext="true"/></security></binding></wsHttpBinding></bindings><behaviors><serviceBehaviors><behavior name="ServiceBehavior"><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="true"/><dataContractSerializer maxItemsInObjectGraph="2147483647" />
                </behavior><behavior name=""><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="false"/></behavior></serviceBehaviors></behaviors><serviceHostingEnvironment multipleSiteBindingsEnabled="true"/></system.serviceModel><system.webServer><directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate"/></system.webServer>
</configuration>

 

 

 直到看到网上的这篇文章后,我修改了我的客户端 binding 类型为 basehttpbinding  后,才解决了。

代码如下:

                BasicHttpBinding binding = new BasicHttpBinding();binding.MaxReceivedMessageSize = int.MaxValue;binding.MaxBufferPoolSize = int.MaxValue;binding.MaxBufferSize = int.MaxValue;string remoteAddress = U8ServiceClient.EndpointAddress.Uri.ToString();EndpointAddress endpoint = new EndpointAddress(remoteAddress);U8Client = new U8ServiceClient(binding, endpoint);

 

 

 

 

 

posted on 2012-11-27 15:12 Alfa 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/wuyifu/archive/2012/11/27/2790824.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/576171.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mybatis xml返回对象类型和接口定义类型不一致

最近在开发中发现xml定义的返回值类型xxxxMaper.xml <select id"selectPlanList" parameterType"Plan" resultMap"PlanListVo">select * from table_name</select> <resultMap type"com.demo.vo.PlanListVo" id"…

算法可视化

http://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html http://jsrun.it/norahiko/oxIy转载于:https://www.cnblogs.com/hailuo/archive/2012/12/06/2805400.html

Springboot @Validated和@Valid的区别 及使用

Valid是使用Hibernate validation的时候使用 Validated是只用Spring Validator校验机制使用 说明&#xff1a;java的JSR303声明了Valid这类接口&#xff0c;而Hibernate-validator对其进行了实现 Validation对Valid进行了二次封装&#xff0c;在使用上并没有区别&#xff0c…

【dp】CF17C. Balance

http://codeforces.com/problemset/problem/17/C 题目中给出一个仅含有a,b,c的字符串&#xff0c;已经两种操作每次选出任意两个相邻的字符&#xff0c;用第一个覆盖掉第二个或者反之&#xff0c;最后询问不考虑操作次数&#xff0c;最终有多少种不同的序列其中a&#xff0c;b,…

git常用的命令收集

1.强制推送&#xff08;慎用&#xff0c;除非你认为其他冲突等可以丢弃 或者不是很重要&#xff09;git push -- force git—全局设置用户名、密码、邮箱 git config命令的–global参数&#xff0c;用了这个参数&#xff0c;表示你这台机器上所有的Git仓库都会使用这个配置&…

git文件操作命令

1.创建文件等小命令 touch a // 创建一个a文件 echo 1234 >> a // 把1234这个内容放入a文件 cat a // 打开a文件 读取出a文件中的内容 mkdir test // 创建test文件夹 rm 文件名 // 删除文件 pwd // 打印当前工作路径2.安装git的时候 都会安装git bash和git GUI 我们完全也…

ECSHOP设置默认配送方式和默认支付方式

用过ECSHOP的站长都知道&#xff0c;首次登陆ECSHOP进行购物的时候&#xff0c;购物流程中没有“默认配送方式和默认支付方式”这个功能 即使网站上只有一种配送方式&#xff0c;它也不会默认选中这个唯一的配送方式。 当你的网站只有一种配送方式&#xff0c;或者&#xff0c;…

spring如何解决循环依赖

什么是循环依赖&#xff1f; 循环依赖其实是指两个及以上bean相互持有对方&#xff0c;最终形成闭环的过程&#xff08;一般聊循环依赖都是默认的单例bean&#xff09;&#xff0c;简单说就是A依赖B,B依赖C,C又依赖A。 下面我就借用别人的网图来解释下&#xff1a; 注意&#…

利用Frame Animation实现动画效果,代码正确,就是达不到变换效果

就是因为把第一帧图片设置成了ImageView的src资源&#xff0c;从而一直覆盖在变换效果之上&#xff0c;去掉ImageView的src属性即可解决。 要想使应用已载入便播放动画效果&#xff0c;直接将 animationDrawables.start(); 放在activity的各种回调函数中&#xff08;onCreate、…

【电信增值业务学习笔记】3 语音类增值业务

作者&#xff1a;gnuhpc 出处&#xff1a;http://www.cnblogs.com/gnuhpc/ 1.一卡多号&#xff1a;&#xff08;Single SIM Multiple Number -SSMN&#xff09; 为拥有一个SIM卡的移动用户提供多个电话号码作为副号码主叫&#xff1a;可以选择用主号码还是副号码发起呼叫被叫&a…

循环依赖源码深度解析

singletonObjects &#xff08;一级缓存&#xff09;它是我们最熟悉的朋友&#xff0c;俗称“单例池”“容器”&#xff0c;缓存创建完成单例Bean的地方。 earlySingletonObjects&#xff08;二级缓存&#xff09;映射Bean的早期引用&#xff0c;也就是说在这个Map里的Bean不是…

java获取异常堆栈详情

/** * 获取exception详情信息 * * param e * Excetipn type * return String type */ public static String getExceptionDetail(Exception e) { StringBuffer msg new StringBuffer("null"); if (e ! null) { msg new StringBuffer(""); String messag…

多线程间共享变量线程安全问题——ThreadLocal

Java并发编程中很重要的类&#xff1a;ThreadLocal 在多线程应用程序中&#xff0c;对共享变量进行读写的场景是很常见的。如果不使用一定的技术或方案&#xff0c;会引发各种线程安全的问题。常见解决线程安全的方式有synchronized、volatile等方式&#xff0c;但synchronized…

我的学生时代之一[小学时代]

真是岁月如梭~ 猛然间这么一掐指&#xff0c;我都毕业4年有余了。先前工作一直不如意&#xff0c;到现在好一点点。 有时候一想&#xff0c;挺怀念上学的时光。 真的是回不去了~ 我又记得多少同学的名字&#xff1f;朋友还有多少常联系的&#xff1f;不很多~ 今天&#xff0c;突…

java8流式操作

简介&#xff1a;Stream 中文称为 “流”&#xff0c;通过将集合转换为这么一种叫做 “流” 的元素序列&#xff0c;通过声明性方式&#xff0c;能够对集合中的每个元素进行一系列并行或串行的流水线操作。 操作分类&#xff1a; .stream() stream()把一个源数据&#xff0c;可…

web.config中httpRunTime的属性

配置httpRuntime也可以让FileUpload上传更大的文件,不过设置太大了会因用户将大量文件传递到该服务器而导致的拒绝服务攻击(属性有说明) <httpRuntime> <httpRuntime useFullyQualifiedRedirectUrl"true|false" maxRequestLength"size in kbytes"…

创建并运用客户化jsp标签

1.在WEB-INF目录下新建message.properties属性文件 文件内容为“key-value”对&#xff0c;添加测试内容如下&#xff1a;titlehello world bodyhello taglib 2.定义初始化类TaglibInit&#xff0c;用…

ArrayList源码阅读

private static void extracted() {ArrayList<StudentVO> arrayList new ArrayList<StudentVO>();arrayList.add(new StudentVO("张三", 23));arrayList.add(new StudentVO("李四", 24));arrayList.add(new StudentVO("王五", 24))…

常用的JS小功能整理

<a href"#" onclick "this.style.behaviorurl(#default#homepage);this.sethomepage(http://www.mingrisoft.com)" style" color:Black; font-size: 9pt; font-family: 宋体; text-decoration :none;" >设置主页</a> <a href&quo…

类的加载过程

类的加载过程 代码 public class Father{private int i test();private static int j method();static{System.out.print("(1)");}Father(){System.out.print("(2)");}{System.out.print("(3)");)public int test(){System.out.print("(…