且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

传入消息的最大消息大小配额 (65536) ....要增加配额,请使用 MaxReceivedMessageSize 属性

更新时间:2021-07-07 00:23:04

您可以通过服务的配置文件在服务上设置 MaxReceivedMessageSize 属性.

You can set the MaxReceivedMessageSize property on the service via the service's config file.

设置客户端的MaxReceivedMessageSize 只影响客户端接收的消息;它对服务收到的消息没有影响.相应地,要允许服务接收大消息,您需要设置服务的配置文件.

Setting the client's MaxReceivedMessageSize only affects messages received by the client; it has no effect on messages received by the service. Correspondingly, to allow the service to receive large messages, you need to set the service's config file.

示例服务配置

<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="MyBinding" maxReceivedMessageSize="2147483647" />
    </wsHttpBinding>
  </bindings>
  <services>
    <service name="MyService">
      <endpoint address="http://myservice" binding="wsHttpBinding"
                bindingConfiguration="MyBinding" contract="IMyServiceContract" />
    </service>
  </services>
</system.serviceModel>

以上是一个非常精简的配置文件,但显示了相关部分.重要的部分是您定义绑定并为其命名,并明确设置与默认值不同的任何值,并在端点元素的 bindingConfiguration 属性中使用该名称.

The above is a very stripped down config file, but shows the relevant parts. The important part is that you define the binding and give it a name, and set any values explicitly that are different from the defaults, and use that name in the bindingConfiguration attribute on the endpoint element.