【问题标题】:WCF Max Message Size ErrorWCF 最大消息大小错误
【发布时间】:2017-05-05 20:17:54
【问题描述】:

我已经为 IStudent 实现了 WCF 服务,其中很少有人会超出传入消息的最大消息大小配额 (65536)。我已经实现了 wsHttpBinding,我也尝试在绑定选项卡下增加消息端,但仍然出现错误,还绑定 maxBufferSize=""... 如果它假设是,则无法识别

最初我在 WCF 测试客户端工具上测试我的服务

App.config

<service name="App.WebServices.Manager.EBSMiddlewareServicesManager" behaviorConfiguration="EBSMiddlewareBehaviorDefault">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:30432/"/>
      </baseAddresses>
    </host>
    <endpoint name="StudentServices" address="StudentServices" binding="wsHttpBinding" contract="App.WebServices.ServiceContract.IStudentServices"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

....

<bindings>
  <wsHttpBinding>
    <binding name="DefaultTransportSecurity" sendTimeout="00:10:00" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="" maxBufferPoolSize="2147483647">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </wsHttpBinding>
</bindings>

错误

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.

Server stack trace: 
at  System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IStudentServices.GetActiveStudentList()
at StudentServicesClient.GetActiveStudentList()

  Inner Exception:
  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.

【问题讨论】:

  • 你要返回 JSON 吗?

标签: c# wcf .net-4.6.2


【解决方案1】:

绑定的MaxReceivedMessageSize 属性是下面错误中超出的值。您需要覆盖该值。您可能还想测试已应用于 readerQuotas 的值。

<wsHttpBinding>
    <binding 
         name="myBinding" 
         maxReceivedMessageSize="2147483647"
     </binding>
</wsHttpBinding>

【讨论】:

  • 但是找到了答案!
【解决方案2】:

我找到了原因,我更新的 app.config 是用于服务器端的,我正在使用 WCF 测试客户端工具来测试我的服务,所以我也需要增加工具端的大小

添加服务,请注意在服务树的末尾有一个“配置文件”节点:右键单击它并选择“使用 SvcConfigEditor 编辑”,获取服务端的确切配置编辑器 - 只需转到绑定设置并更改 MaxReceivedMessageSize 并保存更改。

【讨论】:

  • 您可能还想查看您的服务器配置,因为您放置了一个绑定名称“binding name="DefaultTransportSecurity"”,但不要在配置的服务部分中引用它。您可能必须引用它或删除绑定名称
猜你喜欢
  • 2010-09-27
  • 2015-04-02
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-01
相关资源
最近更新 更多