none
The remote server returned an unexpected response: (413) Request Entity Too Large. RRS feed

  • Question

  • Hello,

    I have a web service, which is deployed and has tested successfully. I also have an application that connects to this web service, again certain calls work just fine. I have one call, where I am passing in a list of an object. once this list hits a certain count (Size) the web service call Responds back with the error "The remote server returned an unexpected response: (413) Request Entity Too Large." I have looked through multiple posts and I have not found an fix that solves my issue. Here is the Web service Config and the Application config for the application requesting the service. As you can see I have maxed out everything in hopes to get around the error. Any help would be greatly appreciated.

    Web Service

    <system.serviceModel> <bindings> <basicHttpBinding> <binding name="EndPointBinding" closeTimeout="00:50:00" openTimeout="00:50:00" receiveTimeout="00:50:00" sendTimeout="00:50:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="None" /> </binding> </basicHttpBinding> </bindings>

     <services>
          <service name="TestServiceLibrary.TestService" behaviorConfiguration="ServiceWithMetadata">

    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="EndPointBinding"
              name="IShipments" contract="TestServiceLibrary.IShipments">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>

          </service>
        </services>

    <behaviors>
          <serviceBehaviors>
              <behavior name="ServiceWithMetadata">
                   <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                   <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>

    App Config
    <system.serviceModel>
            <bindings>
                <basicHttpBinding>
     <binding name="BasicHttpBinding_IShipments" closeTimeout="00:11:00"
                        openTimeout="00:11:00" receiveTimeout="00:11:00" sendTimeout="00:11:00"
                        allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="2097152"
                        maxBufferSize="2097152" maxReceivedMessageSize="2097152" transferMode="Buffered">
                        <readerQuotas maxDepth="2097152" maxStringContentLength="2097152"
                            maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
                    </binding>
                </basicHttpBinding>
            </bindings>
    <client>
    <endpoint address="http://testserver/TestServiceLibrary.TestService.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IShipments"
                    contract="TestWebService.IShipments" name="BasicHttpBinding_IShipments" />
    </client>
        </system.serviceModel>


    Tuesday, September 23, 2014 3:44 PM

Answers

All replies

  • The srvice-side bindings are being ignored, and the defult settings are still being used.

    You must use a Custom Binding on the service-side to change readerquotas settings and things of that nature, and the service-side has to point to Custom Bindings.

    http://blogs.msdn.com/b/kaevans/archive/2008/01/24/wcf-and-custom-bindings.aspx

    Tuesday, September 23, 2014 8:57 PM
  • Okay, so based on reading that article, I went and created a custom binding, binding. I assigned all the endpoints to point to the new custom one, but I am still getting the error Do you see anything that I am missing?

        <bindings>
          <basicHttpBinding>
            <binding name="DataImportServiceSoapBinding" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              allowCookies="false" bypassProxyOnLocal="true" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
              textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
              messageEncoding="Text">
              <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Basic" proxyCredentialType="None"
                  realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
          <customBinding>
              
            <binding name="LargeMessage" closeTimeout="00:05:00" openTimeout="00:05:00"
              receiveTimeout="00:05:00" sendTimeout="00:05:00">
              <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"
                messageVersion="Soap11">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </textMessageEncoding>
              <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                maxBufferSize="2147483647" />
            </binding>
          </customBinding>
        </bindings>
     <services>
          <service behaviorConfiguration="TestServiceBehavior" name="TestServiceLibrary.TestService">
            <endpoint address="" binding="customBinding" bindingConfiguration="LargeMessage"
              name="IShipments" contract="TestServiceLibrary.IShipments">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
     <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/TestServiceLibrary/TestService/" />
              </baseAddresses>
              <timeouts openTimeout="00:02:00" />
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="TestServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>

    Wednesday, September 24, 2014 4:37 PM
  • So are you getting the error when the client is receiving the data or the service is receiving the data? If it's on the client side, then you have to set the readerqouta values and other such settings higher on the client-side, but you don't need the custom binding on the client-side. You just toss in the readerquota parms stuff and increase them.
    Wednesday, September 24, 2014 7:16 PM
  • The service builds fine. I configured the client as well. but when the client calls the web service it immediately receives the error. I looked why in debug mode at the binding settings on the client, and they looked okay, by that I mean they looked like they had the increased values. The error says the server responded with the error. Here is what the client binding config looks like.
     <binding name="BasicHttpBinding_IShipments" closeTimeout="00:11:00"
                        openTimeout="00:11:00" receiveTimeout="00:11:00" sendTimeout="00:11:00"
                        allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="2097152"
                        maxBufferSize="2097152" maxReceivedMessageSize="2097152" transferMode="Buffered">
                        <readerQuotas maxDepth="2097152" maxStringContentLength="2097152"
                            maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
                    </binding>


    Wednesday, September 24, 2014 7:58 PM
  • Those numbers look a little light on the client side as opposed to your service side where you were giving 2,147,483,647 and 2,097,152 on the client side.

    And on the service side config, I don't see you using Custombindings to override anything. Maybe, you should look at some CustomBinding examples in the link.

    http://msdn.microsoft.com/en-us/library/aa347793(v=vs.110).aspx

    Wednesday, September 24, 2014 10:39 PM
  • In the previous post I showed I was using the custom binding for that end point. here it is again below. Based on the link you provided it seems that is what I am doing based on the example of the customer binding transport example. Am I looking in the wrong area? Also Thank you for all your help!
     <customBinding>
              
            <binding name="LargeMessage" closeTimeout="00:05:00" openTimeout="00:05:00"
              receiveTimeout="00:05:00" sendTimeout="00:05:00">
              <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"
                messageVersion="Soap11">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </textMessageEncoding>
              <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                maxBufferSize="2147483647" />
            </binding>
          </customBinding>


    Thursday, September 25, 2014 1:30 PM
  • http://www.codeproject.com/Articles/521725/Request-Entity-Too-Large

    The problem is on the client-side in trying to receive the data sent by the service. The settings are too small on the client side. You try to send the data back to the service, and you would have the same problem. But you overrode the settings on the service side so the service won't have the issue, if it is receiving data sent by the client.

    Thursday, September 25, 2014 3:08 PM
  • Hi RyanO81,

    It seems that you host the WCF Service in the IIS, then please try to increase your httpRutime maxRequestLength to see if it works:

    <system.web> 
      <httpRuntime maxRequestLength="2097152" executionTimeout="120" /> 
    </system.web>


    Besides, please also try to increase the UploadReadAheadSize as described in the following article:
    #(413) Request Entity Too Large:
    http://www.codeproject.com/Articles/521725/Request-Entity-Too-Large .

    Best Regards,
    Amy Peng



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Saturday, September 27, 2014 7:36 AM
    Moderator