2016-12-30 68 views
0

我刚刚研究了很多主题,无法找出原因,但我仍然遇到此问题。 我在服务器上的配置。WCF在增加邮件时仍然会收到最大邮件大小错误

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/> 
    </appSettings> 
    <system.web> 
    <compilation debug="true"/> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="MyService.Services.Service"> 
     <endpoint behaviorConfiguration="LargeDataBehavior" address="" binding="wsHttpBinding" contract="MyService.Services.UI.IService" bindingConfiguration="MyBinding"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/MyService.Services/Service/"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
     <binding bypassProxyOnLocal="True" name="MyBinding" textEncoding="utf-8" 
       maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" 
        maxStringContentLength="2147483647" 
        maxArrayLength="2147483647" 
        maxBytesPerRead="2147483647" 
        maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
      <message clientCredentialType="UserName" algorithmSuite="Default"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="LargeDataBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="True"/> 
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

    <startup> 
    <supportedRuntime version="v2.0.50727"/> 
    </startup> 
</configuration> 

然后我运行WCF Test Client。

传入消息的最大消息大小配额(65536)已被超出。要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

内部异常: 传入消息的最大消息大小配额(65536)已被超出。要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

对不起,我的英语不好。 非常感谢您的帮助!

回答

2

基于错误,这听起来像你需要增加maxReceivedMessageSize属性在WCFTestClient配置,而不是服务。

为此,请转到WCFTestClient左侧的底部并右键单击配置文件节点,然后选择“使用SvcConfigEditor编辑”。

enter image description here

在弹出的窗口中选择要编辑的结合,并根据需要在右侧窗格中,您可以调整所有的值。

enter image description here

注意,这只会坚持认为WCFTestClient会议;一旦你关闭它,你会失去设置,它会恢复到默认值。

+0

它适合我。 – vutx

0

似乎配置对服务不正确,因为在端点级别应用绑定配置后,它仍然给最大大小提供同样的问题。 您的绑定配置是正确的,但行为配置应该位于服务级别而不是终点级别。

behaviorConfiguration="newBehaviour"行为添加到服务级别节点,即'<services>'标记,并且您可以删除端点标记上的行为,因为行为是服务级别,因此请在服务标记上指定您的行为配置。

<system.serviceModel> 
    <services name="MyService.Services.Service" behaviorConfiguration="newBehaviour" > 
    <endpoint address="" binding="wsHttpBinding" contract="MyService.Services.UI.IService" bindingConfiguration="MyBinding"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
       <add baseAddress="http://localhost:8733/MyService.Services/Service/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
     <binding bypassProxyOnLocal="True" name="MyBinding" textEncoding="utf-8" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
       <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="LargeDataBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="newBehaviour"> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" /> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 
+0

这不是我的问题家伙。我做到了,仍然是一样的错误。感谢您的建议。 – vutx

+0

好的,看起来您已将最大大小设置添加到您的客户端应用程序中,从您使用WCF服务的位置开始,我认为您还必须将这些设置添加到WCF服务中。 –

相关问题