Ошибка максимального размера сообщения WCF

Я реализовал службы WCF для IStudent, и некоторые из них превышают квоту максимального размера сообщения для входящих сообщений (65536). Я реализовал wsHttpBinding, также я попытался увеличить сторону сообщения на вкладке привязок, но все еще получаю ошибку, а также привязку maxBufferSize = "" ... не распознается, если предполагается, что это

Сначала я тестирую свой сервис на WCF Test Client Tool.

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.

person Toxic    schedule 20.12.2016    source источник
comment
Вы возвращаете JSON?   -  person Ross Bush    schedule 20.12.2016


Ответы (2)


Свойство MaxReceivedMessageSize привязки - это то, что превышено в приведенной ниже ошибке. Вам нужно переопределить это значение. Вы также можете проверить значения, которые вы применили к readerQuotas.

<wsHttpBinding>
    <binding 
         name="myBinding" 
         maxReceivedMessageSize="2147483647"
     </binding>
</wsHttpBinding>
person Ross Bush    schedule 20.12.2016
comment
однако нашел ответ! - person Toxic; 20.12.2016

Я нашел причину, app.config, который я обновил, предназначен для серверной части, и я использую инструмент WCF Test Client для тестирования своих служб, поэтому мне также нужно увеличить размер на стороне инструмента.

добавить службу, обратите внимание, что в конце дерева служб есть узел «файл конфигурации»: щелкните его правой кнопкой мыши и выберите «редактировать с помощью SvcConfigEditor», получите точный редактор конфигурации для стороны службы - просто перейдите к настройкам привязки и измените MaxReceivedMessageSize и сохраните изменения.

person Toxic    schedule 20.12.2016
comment
Вы также можете посмотреть конфигурацию своего сервера, когда вы помещаете привязку имени привязки name = DefaultTransportSecurity, но не ссылаетесь на нее в служебной части вашей конфигурации. Возможно, вам придется сослаться на него или удалить имя привязки - person user1628733; 20.12.2016