简体   繁体   English

Azure WCF服务上的maxReceivedMessageSize太小

[英]maxReceivedMessageSize on Azure WCF service is too small

Whenever I connect my client to send data to my WCF Azure service, I get this error: 每当我连接客户端以将数据发送到WCF Azure服务时,都会出现此错误:

"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element." “超出了传入消息的最大消息大小配额(65536)。要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。”

I've read everywhere about setting this MaxReceivedMessageSize property on both the client and server config files. 我到处都读过有关在客户端和服务器配置文件上设置此MaxReceivedMessageSize属性的信息。 I have done this. 我已经做到了。

However, whenever I update the service reference in the client, it pulls the settings back to the default of 65536. (found via investigating the .svcinfo file) 但是,每当我在客户端中更新服务引用时,它都会将设置拉回到默认值65536。(可通过调查.svcinfo文件找到)

This leads me to conclude the issue must be on the service side. 这使我得出结论,问题必须在服务端。

I've placed this in my web.config file: 我将其放置在我的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>

Now, many posts talk about naming the binding and setting it in the service endpoints on the server side as well. 现在,许多帖子都讨论了如何命名绑定并在服务器端的服务端点中设置绑定。 Something like this: 像这样:

<services>
   <service name="YourNamespace.YourServiceClass">
       <endpoint name="endpoint1"
             address="http://server:8888/YourService.svc" 
             binding="basicHttpBinding"
             bindingConfiguration="lageMessageTransfer"
             contract="IYourServiceContract" />
   </service>
</services>

However, I don't have these service endpoints and my service works great for small sizes. 但是,我没有这些服务端点,因此我的服务在小尺寸情况下效果很好。

Where else would this need to be set? 还有什么地方需要设置?

EDIT: 编辑:

More information, Tim seems to be on the right track with the default endpoints. 有关更多信息,Tim似乎在使用默认端点的正确轨道上。 I am using a default endpoint. 我正在使用默认端点。 It seems that you cannot just explicitly define a service for that default endpoint. 似乎您不能仅仅为该默认终结点显式定义服务。 or if you can, I must be doing it incorrectly. 或者如果可以的话,我一定做错了。

However, it seems that you can modify the binding on a default endpoint as stated by Richard. 但是,似乎您可以按照Richard所述修改默认端点上的绑定。 This is done by simply not specifying a name for the binding. 只需不指定绑定名称即可完成此操作。 I have tried setting the values on my service to much lower values to see if something else was lowering them, but they are completely ignored. 我尝试将服务上的值设置为低得多的值,以查看是否有其他因素正在降低它们,但是它们被完全忽略了。 Its as if the default endpoint is simply ignoring the binding that I have created. 好像默认端点只是忽略我创建的绑定一样。

For my entire config file: 对于我的整个配置文件:

<?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>

Thoughts on why the new binding settings are not being picked up? 关于为什么不选择新的绑定设置的想法?

The attribute name maxReceivedMessageSize is very explicit - it all depends on who is receiving the message - if you are sending a large amount of data then it is the service, if you are getting a large amount of data back from the service then it is the client. 属性名称maxReceivedMessageSize是非常明确的-这完全取决于接收消息的人-如果要发送大量数据,则它是服务,如果要从服务中获取大量数据,则它是服务。客户。 The service and client do not need the same value for this setting (unlike many other binding settings) 服务和客户端不需要为此设置使用相同的值(与许多其他绑定设置不同)

Setting an unnamed binding section should work in general as, of .NET 4, it configures the binding for anyone who doesn't explicitly specify a configuration using bindingConfiguration. 从.NET 4开始,设置未命名的绑定部分通常应该起作用,它为未使用bindingConfiguration明确指定配置的任何人配置绑定。 However, in your example above you need to set the maxBufferSize in addition to the maxReceivedMessageSize as you are buffering rather than streaming the message. 但是,在上面的示例中,您在缓冲而不是流式传输消息时,除了maxReceivedMessageSize之外,还需要设置maxBufferSize。 The maxBufferSize and maxReceivedMessageSize must be the same maxBufferSize和maxReceivedMessageSize必须相同

You don't have the section in the Web.config on your service side? 您在服务端的Web.config中没有该部分吗? If you're using WCF 4.0 is it possible you're using a default endpoint? 如果使用的是WCF 4.0,是否可以使用默认端点?

I don't know if you can specify a binding for a default endpoint, but you might want to try specifying an endpoint via the section of the Web.config and setting bindingConfiguration to the binding specified in your section. 我不知道是否可以为默认终结点指定绑定,但是您可能想尝试通过Web.config的部分指定终结点,并将bindingConfiguration设置为您的部分中指定的绑定。

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

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