【发布时间】:2011-06-17 01:23:37
【问题描述】:
每当我连接我的客户端以将数据发送到我的 WCF Azure 服务时,我都会收到此错误:
“已超出传入邮件的最大邮件大小配额 (65536)。 增加配额,在适当的绑定上使用 MaxReceivedMessageSize 属性 元素。”
我到处都在阅读有关在客户端和服务器配置文件上设置此 MaxReceivedMessageSize 属性的信息。我已经这样做了。
但是,每当我在客户端更新服务引用时,它会将设置拉回默认值 65536。(通过调查 .svcinfo 文件找到)
这使我得出结论,问题一定出在服务端。
我已将它放在我的 web.config 文件中:
<bindings>
<basicHttpBinding>
<!--The basicHttpBinding is used for clients which use the generated code to transmit data; the following settings make it possible to send larger amounts to the service-->
<binding maxReceivedMessageSize="10000000" receiveTimeout="01:00:00">
<readerQuotas maxStringContentLength="10000000" />
</binding>
</basicHttpBinding>
</bindings>
现在,许多帖子都在讨论命名绑定并将其设置在服务器端的服务端点中。像这样的:
<services>
<service name="YourNamespace.YourServiceClass">
<endpoint name="endpoint1"
address="http://server:8888/YourService.svc"
binding="basicHttpBinding"
bindingConfiguration="lageMessageTransfer"
contract="IYourServiceContract" />
</service>
</services>
但是,我没有这些服务端点,而且我的服务非常适合小尺寸。
这还需要在哪里设置?
编辑:
更多信息,Tim 似乎在使用默认端点的正确轨道上。我正在使用默认端点。似乎您不能只为该默认端点明确定义服务。或者如果可以的话,我一定是做错了。
但是,您似乎可以按照 Richard 的说明修改默认端点上的绑定。这是通过简单地不为绑定指定名称来完成的。我尝试将我的服务上的值设置为低得多的值,以查看是否有其他东西降低了它们,但它们被完全忽略了。就好像默认端点只是忽略了我创建的绑定。
对于我的整个配置文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="logging.e2e" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="100" maxBufferSize="100" receiveTimeout="00:11:00">
<readerQuotas maxStringContentLength="100" />
</binding>
</basicHttpBinding>
</bindings>
<protocolMapping>
<add scheme="http" binding="basicHttpBinding" />
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<connectionStrings><EDITEDOUT></connectionStrings>
</configuration>
思考为什么新的绑定设置没有被采用?
【问题讨论】:
-
不幸的是,据我所知,如果您无法修改服务的配置,您就会陷入困境。如果您绝对无法修改服务的配置,则需要采取措施确保您的有效负载小于最大 65536 字节。
-
我可以修改服务器的配置,但是它不会接受新的设置。