WCF服务错误413实体太大

Ang*_*elo 1 wcf

需要一些关于在哪里查看与WCF错误相关的一些信息我得到的请求实体太大(错误413).

实际上,该服务是一个简单的[OperationContract]接受字符串作为参数.

<IService.cs>
[OperationContract]
string UploadReportText(string ReportText);


<Service.cs>
public string UploadReportText(string ReportText)
{
  // Code to process data passed.
}
Run Code Online (Sandbox Code Playgroud)

我已经为服务设置了web配置,如下所示:

<bindings>
 <webHttpBinding>
    <binding maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647"
                    maxStringContentLength="2147483647"
                    maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
   </binding>
 </webHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)

虽然我认为不需要触及IIS中的uploadReadAhead值(因为我没有使用SSL),但我仍然将其修改为值2147483647.

跟踪其中一个在Chrome中调用该服务的应用,我可以看到数据Content-Length是169786.

真的难倒哪里看起来与此有关.

欣赏任何洞察力.谢谢

更新:附加信息如果我将传递给服务的字符串数据设置为较小的长度,我没有收到错误.我所做的大部分搜索都涉及到maxReceivedMessageSize需要调整到最大可能值,但在web配置中设置它似乎没有任何效果.

更新: 启用日志记录,我收到此消息:

例外细节: System.ServiceModel.ProtocolException: 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.

Vig*_*r A 6

首先:在服务器端,您可以定义具有更大消息大小的绑定配置,但不要从端点引用它.

  <service behaviorConfiguration="WCFReferrals.Service1Behavior"
             name="WCFReferrals.Referrals">
       <endpoint 
             address="" 
             binding="wsHttpBinding" 
             bindingConfiguration="LargeSizeMessages"  <== you need to reference the binding config (by specifying its name
            contract="WCFReferrals.IReferrals">
        </endpoint>
        .....
      </service>
      ....
      <binding name="LargeSizeMessages"   <== give it a meaningful name
           maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
           <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
               maxArrayLength="2147483647" maxBytesPerRead="4096" 
               maxNameTableCharCount="16384" />
      </binding>
Run Code Online (Sandbox Code Playgroud)

资源

请参阅此处