已超出传入邮件的最大邮件大小限额(65536)

时间:2011-10-17 17:20:45

标签: silverlight wcf

我有一个在另一个项目中调用WCF服务的silverlight应用程序(相同的解决方案) 问题是我得到了所有常见错误65536 我已经阅读了大量的文章,我已经尝试了所有仍然收到此消息。

这是我的Web服务

<system.web>
  <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  <httpRuntime maxRequestLength="2147483647"/>
  <customErrors mode="Off"/>
</system.web>
<system.serviceModel>
  <services>
    <service behaviorConfiguration="ServiceBehavior" name="MyRemoteHostService">
      <endpoint address="" binding="basicHttpBinding" 
                bindingConfiguration="BasicHttpBinding_MyRemoteHostService"
                contract="MyServiceReference.MyRemoteHostService" />

      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
  </services>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="false"
                             multipleSiteBindingsEnabled="true" />
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_MyRemoteHostService"
               maxBufferPoolSize="2147483647"
               maxReceivedMessageSize="2147483647"
               maxBufferSize="2147483647">
        <readerQuotas maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647"
                      maxDepth="2147483647"
                      maxNameTableCharCount="2147483647"
                      maxStringContentLength="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior name="ServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

这是我的客户端ServiceReferences.ClientConfig

<system.web>
  <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  <httpRuntime maxRequestLength="2147483647"/>
  <customErrors mode="Off"/>
</system.web>
<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_MyRemoteHostService" 
               closeTimeout="00:01:00"
               openTimeout="00:01:00" 
               receiveTimeout="00:05:00" 
               sendTimeout="00:02:00"
               maxBufferSize="2147483647" 
               maxReceivedMessageSize="2147483647">
        <security mode="None"></security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://localhost:2622/MyRemoteHostService.svc"
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_MyRemoteHostService"
              contract="MyServiceReference.MyRemoteHostService"
                name="BasicHttpBinding_MyRemoteHostService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </client>
</system.serviceModel>

4 个答案:

答案 0 :(得分:0)

查看客户端配置文件。我怀疑你的错误来自哪里。

答案 1 :(得分:0)

试试这个:

<binding name="higherMessageSize" maxReceivedMessageSize="2147483647">
     <readerQuotas maxStringContentLength="2147483647" />
</binding>

答案 2 :(得分:0)

我发现了这个问题;命名空间未在服务名称中设置

<service behaviorConfiguration="ServiceBehavior" name="MyRemoteHostService"> 

更改为

<service behaviorConfiguration="ServiceBehavior" name="My.Framework.Web.MyRemoteHostService"> 

答案 3 :(得分:0)

谢谢用户958015我解决了它的方式与你一样,我没有在网络服务方面有这个部分

<services>
<service behaviorConfiguration="ServiceBehavior" name="MyRemoteHostService">
  <endpoint address="" binding="basicHttpBinding" 
            bindingConfiguration="BasicHttpBinding_MyRemoteHostService"
            contract="MyServiceReference.MyRemoteHostService" />

  <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

Silverlight中不存在“readerQuotas”属性,您只需要确保在Web服务和客户端中具有相同的属性,并确保在Web服务端编写名称和命名空间