简体   繁体   中英

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:

HTTP/1.1 413 Request Entity Too Large

The request is welll under my specified maximum request length (2147483647) so I have no idea why this is happening.

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.

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). 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:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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