繁体   English   中英

Silverlight和WCF:最大邮件大小

[英]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攻击)。

在服务器端,更改配置文件以使服务可以接受大消息。

  1. <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> ....... 
  2. 将配置添加到服务绑定。

     <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" contract="WcfService1.IService1"> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM