Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 已超过传入邮件的最大邮件大小配额(65536)_C#_Wcf_Maxreceivedmessagesize - Fatal编程技术网

C# 已超过传入邮件的最大邮件大小配额(65536)

C# 已超过传入邮件的最大邮件大小配额(65536),c#,wcf,maxreceivedmessagesize,C#,Wcf,Maxreceivedmessagesize,我的WCF服务有一个OperationContract,它接受对象数组作为参数。这可能相当大。在查找错误请求400的修复程序后,我找到了真正的原因:最大消息大小 我知道这个问题以前在很多地方都被问过。我试过大家说的:“增加客户端和服务器配置文件的大小。”我试过了。它仍然不起作用 我的服务的web.config: <system.serviceModel> <services> <service name="myService">

我的WCF服务有一个OperationContract,它接受对象数组作为参数。这可能相当大。在查找错误请求400的修复程序后,我找到了真正的原因:最大消息大小

我知道这个问题以前在很多地方都被问过。我试过大家说的:“增加客户端和服务器配置文件的大小。”我试过了。它仍然不起作用

我的服务的web.config:

<system.serviceModel>
    <services>
      <service name="myService">
        <endpoint name="myEndpoint" address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="myBinding"
                  contract="Meisel.WCF.PDFDocs.IPDFDocsService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="myBinding"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:15:00"
                 sendTimeout="00:15:00"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="Buffered"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我的客户端的app.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPDFDocsService"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:11:00"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 transferMode="Buffered"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None"
                       proxyCredentialType="None"
                       realm="" />
            <message clientCredentialType="UserName"
                     algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8451/PDFDocsService.svc"
                behaviorConfiguration="MoreItemsInObjectGraph"
                binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IPDFDocsService"
                contract="PDFDocsService.IPDFDocsService"
                name="BasicHttpBinding_IPDFDocsService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MoreItemsInObjectGraph">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

我可能会错过什么或做错什么?服务似乎忽略了我在maxReceivedBufferSize中输入的内容

提前感谢,, 凯尔

更新

以下是另外两个他们从未得到答案的问题:


在服务配置文件中,元素中缺少“name”属性

<behaviors>
  <serviceBehaviors>
    <behavior name="StackOverflow">

在服务元素中应该有对该名称的引用:

<system.serviceModel>
    <services>
        <service behaviorConfiguration="StackOverflow" name="myService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding"


我在WCF测试中遇到了同样的问题,并且正确地设置了配置文件。如果您的配置文件中没有任何问题,我建议尝试使用另一个程序测试该服务,例如:SOAP UI,我认为此错误不是来自该服务,而是来自WCF测试。

乍一看似乎正确。您是否在任何地方配置代码中的端点?如果是这样,那可能会覆盖配置设置。您是如何托管服务的?IIS?@Jeff:我只是在创建我的服务客户端的一个新实例,然后调用OperationContract,将我的自定义类作为参数传入。没什么特别的@西蒙:我正在使用ASP.NET开发服务器。目前,它都是本地的。如果我告诉你,当我向我的行为添加名称时,WCFTestClient会告诉我错误:“错误:无法获取元数据。元数据包含无法解析的引用。内容类型应用程序/soap+xml;服务不支持字符集=utf-8。客户端和服务绑定可能不匹配。远程服务器返回错误:(415)不支持的媒体类型。HTTP GET。HTML文档不包含Web服务发现信息。“这就是为什么我没有为我的行为命名。我仍然不确定这个问题的真正解决方案是什么,但我能够解决我原来的问题,使这个问题变得毫无意义。FWIW,通过确保我的服务使用了behaviorConfiguration,似乎我能够摆脱上述错误。谢谢