简体   繁体   English

即使更新web.config后,请求实体也太大

[英]Request Entity Too Large Even After Updating web.config

I have a very annoying issue, where my WCF service orks fine for most requests, but for a particular large request, I am getting this error in my header: 我有一个很烦人的问题,我的WCF服务可以处理大多数请求,但是对于特定的大请求,我的标头中出现此错误:

HTTP/1.1 413 Request Entity Too Large HTTP / 1.1 413请求实体太大

The request is welll under my specified maximum request length (2147483647) so I have no idea why this is happening. 该请求低于我指定的最大请求长度(2147483647),所以我不知道为什么会这样。

These are the settings I added to my config file to overcome this, but nothing is working: 这些是我添加到配置文件中以克服此问题的设置,但没有任何效果:

<httpRuntime maxRequestLength="2147483647" />

<behavior>
  <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>

<basicHttpBinding>
    <binding name="secureHttpBinding"
             maxBufferPoolSize="2147483647"
             maxReceivedMessageSize="2147483647"
             maxBufferSize="2147483647" 
             transferMode="Streamed">
        <readerQuotas 
          maxStringContentLength="2147483647"
          maxArrayLength="2147483647"
          maxBytesPerRead="2147483647"
          maxDepth="64"
          maxNameTableCharCount="2147483647"/>
    </binding>
</basicHttpBinding>

I have also included the entire config file below. 我还包括了下面的整个配置文件。 Can anyone help me understand what is going wrong here? 谁能帮助我了解这里出了什么问题?

I do not have access to the client which sends these messages in live, but I am testing using Soap UI. 我没有访问实时发送这些消息的客户端的权限,但是我正在使用Soap UI进行测试。

Thank you 谢谢

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="AccessConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Bassie\Desktop\Biz Backoffice.mdb" />
    <add name="LogPath" connectionString="C:\Test\pnp\pnp.log" />
    <add name="ErrorPath" connectionString="C:\Test\pnp\errors" />
  </connectionStrings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="2147483647" />
  </system.web>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

      </serviceBehaviors>

    </behaviors>

    <services>
      <service name="WCFService1.Service1">
        <endpoint address="http://Biz.ddns.net/Service1.svc" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="secureHttpBinding" 
                  contract="WCFService1.IService1"
                  />
        <!--<endpoint address="mex" binding="mexHttpsBinding" 
                  contract="IMetadataExchange" />-->
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647" 
                 transferMode="Streamed">
            <readerQuotas 
              maxStringContentLength="2147483647"
              maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
              maxDepth="64"
              maxNameTableCharCount="2147483647"/>

            <security mode="Transport">
              <transport clientCredentialType="Basic" />
            </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

Here is an example message (wrapped in Soap envelope when being sent of course). 这是一个示例消息(发送时自然会包裹在Soap信封中)。 You will notice that there are only 2 receivingAdviceItemContainmentLineItem elements, but the message which is giving me the problemn contains about 50. Note that the complete message which is not working is around 128kb in size when saved to a file: 你会发现,只有2个receivingAdviceItemContainmentLineItem元素,但它给我problemn消息包含约50注意,这是不工作的完整的消息是各地大小128KB,当保存到一个文件:

<sh:StandardBusinessDocument
    xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
    xmlns:deliver="urn:ean.ucc:deliver:2"
    xmlns:eanucc="urn:ean.ucc:2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sh:StandardBusinessDocumentHeader>
        <sh:HeaderVersion>1.0</sh:HeaderVersion>
        <sh:Sender>
            <sh:Identifier Authority="EAN.UCC">6001000000001</sh:Identifier>
        </sh:Sender>
        <sh:Receiver>
            <sh:Identifier Authority="EAN.UCC">6001007805159</sh:Identifier>
        </sh:Receiver>
        <sh:DocumentIdentification>
            <sh:Standard>EAN.UCC</sh:Standard>
            <sh:TypeVersion>2.5</sh:TypeVersion>
            <sh:InstanceIdentifier>0000000643343333</sh:InstanceIdentifier>
            <sh:Type>ReceivingAdvice</sh:Type>
            <sh:MultipleType>false</sh:MultipleType>
            <sh:CreationDateAndTime>2017-06-22T00:00:00</sh:CreationDateAndTime>
        </sh:DocumentIdentification>
    </sh:StandardBusinessDocumentHeader>
    <eanucc:message>
        <entityIdentification>
            <uniqueCreatorIdentification>G_REC_5005721318</uniqueCreatorIdentification>
            <contentOwner>
                <gln>6001000000001</gln>
            </contentOwner>
        </entityIdentification>
        <eanucc:transaction>
            <entityIdentification>
                <uniqueCreatorIdentification>G_REC_5005721318</uniqueCreatorIdentification>
                <contentOwner>
                    <gln>6001000000001</gln>
                </contentOwner>
            </entityIdentification>
            <command>
                <eanucc:documentCommand>
                    <documentCommandHeader type="ADD">
                        <entityIdentification>
                            <uniqueCreatorIdentification />
                            <contentOwner>
                                <gln>6001000000001</gln>
                            </contentOwner>
                        </entityIdentification>
                    </documentCommandHeader>
                    <documentCommandOperand>
                        <deliver:receivingAdvice creationDateTime="2017-06-22T00:00:00" documentStatus="ORIGINAL">
                            <documentStructureVersion>
                                <versionIdentification>2.5</versionIdentification>
                            </documentStructureVersion>
                            <reportingCode>CONFIRMATION</reportingCode>
                            <receivingAdviceIdentification>
                                <uniqueCreatorIdentification>G_REC_5005721318</uniqueCreatorIdentification>
                                <contentOwner>
                                    <gln>6001000000001</gln>
                                </contentOwner>
                            </receivingAdviceIdentification>
                            <shipTo>
                                <gln>6001007022334</gln>
                                <additionalPartyIdentification>
                                    <additionalPartyIdentificationValue>MA08</additionalPartyIdentificationValue>
                                    <additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
                                </additionalPartyIdentification>
                            </shipTo>
                            <shipper>
                                <gln>6001007805159</gln>
                            </shipper>
                            <receiver>
                                <gln>6001007022334</gln>
                            </receiver>
                            <receivingAdviceItemContainmentLineItem number="0001">
                                <containedItemIdentification>
                                    <gtin>16001000806532</gtin>
                                    <additionalTradeItemIdentification>
                                        <additionalTradeItemIdentificationValue>109395</additionalTradeItemIdentificationValue>
                                        <additionalTradeItemIdentificationType>SUPPLIER_ASSIGNED</additionalTradeItemIdentificationType>
                                    </additionalTradeItemIdentification>
                                    <additionalTradeItemIdentification>
                                        <additionalTradeItemIdentificationValue>client GEM SQUASH LS 1PK</additionalTradeItemIdentificationValue>
                                        <additionalTradeItemIdentificationType>BUYER_ASSIGNED</additionalTradeItemIdentificationType>
                                    </additionalTradeItemIdentification>
                                    <additionalTradeItemIdentification>
                                        <additionalTradeItemIdentificationValue>000000000000109395</additionalTradeItemIdentificationValue>
                                        <additionalTradeItemIdentificationType>BUYER_ASSIGNED</additionalTradeItemIdentificationType>
                                    </additionalTradeItemIdentification>
                                </containedItemIdentification>
                                <specification number="0">
                                    <reference>
                                        <referenceDateTime>0000-00-00T00:00:00.000</referenceDateTime>
                                        <referenceIdentification>NFI72449</referenceIdentification>
                                    </reference>
                                </specification>
                                <purchaseOrder>
                                    <documentReference creationDateTime="0000-00-00T00:00:00.000">
                                        <uniqueCreatorIdentification>4529222808</uniqueCreatorIdentification>
                                        <contentOwner>
                                            <gln>6001000000001</gln>
                                        </contentOwner>
                                    </documentReference>
                                </purchaseOrder>
                                <quantityAccepted>
                                    <value>9.000</value>
                                    <unitOfMeasure>
                                        <measurementUnitCodeValue>CK2</measurementUnitCodeValue>
                                    </unitOfMeasure>
                                </quantityAccepted>
                                <quantityReceived>
                                    <value>9.000</value>
                                    <unitOfMeasure>
                                        <measurementUnitCodeValue>CK2</measurementUnitCodeValue>
                                    </unitOfMeasure>
                                </quantityReceived>
                                <receivingConditionInformation>
                                    <receivingCondition>GOOD_CONDITION</receivingCondition>
                                    <receivingConditionQuantity>
                                        <value>9</value>
                                    </receivingConditionQuantity>
                                </receivingConditionInformation>
                            </receivingAdviceItemContainmentLineItem>
                            <receivingAdviceItemContainmentLineItem number="0002">
                                <containedItemIdentification>
                                    <gtin>96001007182697</gtin>
                                    <additionalTradeItemIdentification>
                                        <additionalTradeItemIdentificationValue>392007</additionalTradeItemIdentificationValue>
                                        <additionalTradeItemIdentificationType>SUPPLIER_ASSIGNED</additionalTradeItemIdentificationType>
                                    </additionalTradeItemIdentification>
                                    <additionalTradeItemIdentification>
                                        <additionalTradeItemIdentificationValue>thirdparty PLASTIC CRATE</additionalTradeItemIdentificationValue>
                                        <additionalTradeItemIdentificationType>BUYER_ASSIGNED</additionalTradeItemIdentificationType>
                                    </additionalTradeItemIdentification>
                                    <additionalTradeItemIdentification>
                                        <additionalTradeItemIdentificationValue>000000000000392007</additionalTradeItemIdentificationValue>
                                        <additionalTradeItemIdentificationType>BUYER_ASSIGNED</additionalTradeItemIdentificationType>
                                    </additionalTradeItemIdentification>
                                </containedItemIdentification>
                                <specification number="0">
                                    <reference>
                                        <referenceDateTime>0000-00-00T00:00:00.000</referenceDateTime>
                                        <referenceIdentification>NFI72449</referenceIdentification>
                                    </reference>
                                </specification>
                                <purchaseOrder>
                                    <documentReference creationDateTime="0000-00-00T00:00:00.000">
                                        <uniqueCreatorIdentification>4529222808</uniqueCreatorIdentification>
                                        <contentOwner>
                                            <gln>6001000000001</gln>
                                        </contentOwner>
                                    </documentReference>
                                </purchaseOrder>
                                <quantityAccepted>
                                    <value>9.000</value>
                                    <unitOfMeasure>
                                        <measurementUnitCodeValue>EA</measurementUnitCodeValue>
                                    </unitOfMeasure>
                                </quantityAccepted>
                                <quantityReceived>
                                    <value>9.000</value>
                                    <unitOfMeasure>
                                        <measurementUnitCodeValue>EA</measurementUnitCodeValue>
                                    </unitOfMeasure>
                                </quantityReceived>
                                <receivingConditionInformation>
                                    <receivingCondition>GOOD_CONDITION</receivingCondition>
                                    <receivingConditionQuantity>
                                        <value>9</value>
                                    </receivingConditionQuantity>
                                </receivingConditionInformation>
                            </receivingAdviceItemContainmentLineItem>
                            <receiptInformation>
                                <receivingDateTime>2017-06-22T00:00:00</receivingDateTime>
                            </receiptInformation>
                            <consignmentIdentification>
                                <referenceDateTime>2017-06-22T00:00:00</referenceDateTime>
                                <referenceIdentification>NFI72449</referenceIdentification>
                            </consignmentIdentification>
                        </deliver:receivingAdvice>
                    </documentCommandOperand>
                </eanucc:documentCommand>
            </command>
        </eanucc:transaction>
    </eanucc:message>
</sh:StandardBusinessDocument>

I changed my web.config so that it looks like this: 我更改了web.config ,使其看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="AccessConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Bassie\Desktop\AllwaysFresh Backoffice.mdb" />
    <add name="LogPath" connectionString="C:\Test\pnp\pnp.log" />
    <add name="ErrorPath" connectionString="C:\Test\pnp\errors" />
  </connectionStrings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="2097151" />
  </system.web>

  <system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2097151"/>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

      </serviceBehaviors>

    </behaviors>

    <services>
      <service name="Service1">
        <endpoint address="" 
                  binding="basicHttpBinding" 
                  contract="IService1"
                  />
      </service>
    </services>

    <bindings>  
      <basicHttpBinding>
        <binding maxBufferPoolSize="2097151"
                 maxReceivedMessageSize="2097151"
                 maxBufferSize="2097151" 
                 transferMode="Streamed">
            <readerQuotas 
              maxStringContentLength="2097151"
              maxArrayLength="2097151"
              maxBytesPerRead="2097151"
              maxDepth="2097151"
              maxNameTableCharCount="2097151"/>
        </binding>
      </basicHttpBinding>

    </bindings>

  </system.serviceModel>

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483648" />
      </requestFiltering>
    </security>

    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

And it now seems to work... 现在它似乎起作用了...

I changed various bits of the configuration file, none of which seem particularly relevant, so not sure why it works. 我更改了配置文件的各个位,这些位似乎都没有特别的关系,因此不确定为什么它可以工作。 If anyone could shed some light on this that would be great. 如果有人能对此有所启示,那将是很棒的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM