WCF服务错误413实体太大

 Carre陈 发布于 2023-02-09 15:27

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

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


[OperationContract]
string UploadReportText(string ReportText);



public string UploadReportText(string ReportText)
{
  // Code to process data passed.
}

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


 
    
      
   
 

虽然我认为不需要触及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.

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

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

    资源

    请参阅此处

    2023-02-09 15:30 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有