[英]Silverlight & WCF: Max message size
當我使用WCF從我的silverlight應用程序中傳遞一個對象列表時,一切正常,直到List變得太大。 似乎當我超過80個項目時,我收到錯誤:遠程服務器返回了意外的響應:(404)Not Found
我認為這是因為List已經變得太大了,就像List有70個物品一樣可以正常工作。 但是奇怪的錯誤信息,對嗎?
在配置文件中,我將maxBufferSize更改為它將接受的最高值,但我的列表中仍然不能有超過80個項目。
如何在不拆分對象的情況下傳遞大對象?
謝謝肖恩,我到底該怎么做? 這是我的ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<client>
<!--"http://sy01911.fw.gsjbw.com/WcfService1/Service1.svc"-->
<endpoint address="http://localhost/WcfService1/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService11"
contract="SilverlightApplication1.ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="655360000"
maxReceivedMessageSize="655360000">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_IService11" maxBufferSize="655360000"
maxReceivedMessageSize="655360000">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
這是您提到的服務器配置
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior" >
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" >
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
如果從WCF發送大量項目,還要確保maxItemsInObjectGraph是一個相對較高的數字
<behaviors>
<serviceBehaviors>
<behavior name="YourBahvior">
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
</behaviors>
有兩個配置文件。 silverlight clientconfig將允許您發送更大的消息,但如果您正在使用WCF,則有一個服務器web.config限制接收消息的大小(以防止DDOS攻擊)。
在服務器端,更改配置文件以使服務可以接受大消息。
在<system.serviceModel>
部分中添加basicHttpBinding
配置:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="MyBasicHttpBinding" maxReceivedMessageSize="300000000"> <security mode="None"/> <readerQuotas maxStringContentLength="300000000"/> </binding> </basicHttpBinding> </bindings> .......
將配置添加到服務綁定。
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" contract="WcfService1.IService1">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.