【已解决,散分】已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性

seraph021724 2013-04-11 04:45:40
先上两个配置文件,我已分别设置MaxReceivedMessageSize 为最大值,标红部分。
[code=客户端]
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>

</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1454/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference3.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
[/code]
[code=服务器端]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="FileUDB" connectionString="D:\dd\"/>
</connectionStrings>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "D:\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<!--获取对象图中要序列化或反序列化的最大项数-->
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="NewBinding0"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None" />

</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

</configuration>
[/code]

配置文件如上,报错信息是
已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。

我传的参数是CompositeType,也就是IService里本来就有的那个,在其中添加了一个ObservableCollection

我在客户端调用的代码如下

ServiceReference3.Service1Client client = new ServiceReference3.Service1Client();
//(client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
//(client.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
ServiceReference3.CompositeType type = new ServiceReference3.CompositeType() { DicFiledInfo = info, IsLast = true, UpStep = 1 };
client.CreateDatasourceAsync(type);
client.CreateDatasourceCompleted += new EventHandler<ServiceReference3.CreateDatasourceCompletedEventArgs>(client_CreateDatasourceCompleted);
client.CloseAsync();


注释部分放开的话仍然会报一样的错误。

我在CSDN上找到一个老帖http://bbs.csdn.net/topics/320086503他是自己new了一个bind,没有调到配置文件。我的情况似乎不一样,求解答。
我用的是Silverlight4.0和VS10
...全文
3470 1 打赏 收藏 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
seraph021724 2013-04-11
  • 打赏
  • 举报
回复
在看过@sunny007sun的帖子http://bbs.csdn.net/topics/360255080后,由他的记录(博客)http://www.cnblogs.com/happyhippy/archive/2011/07/02/2096482.html找到了解决方法。 silverlight自动生成的web.config是没有services的配置信息的,在此需要添加 <services> <service behaviorConfiguration="MyBehavior" name="WcfService1.Service1"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0" contract="WcfService1.IService1" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> 而实际上,service.name与endpoint.contract还是有区别的,contract是协议,对应的是WCF项目下的ServiceContract,也就是接口IService1;而service对应的则是具体调用的svc,也就是Service1。 至此问题解决,感谢@sunny007sun在11年的结贴与博客。

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧