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

  • Question

  • User-1301687005 posted

    I get the the following error when i pass byte array as parameter, what i am missing here .?

    public Folder SplitTiffDocument(byte[] SourceDocument, List<Folder> folder)

    Service web.config

    <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="CustomWSBindingHttp" maxReceivedMessageSize="2147483647">
              <reliableSession enabled="false"/>
            </binding>
          </wsHttpBinding>
          <netTcpBinding>
            <binding name="CustomWSBindingTcp">
              <reliableSession enabled="true"/>
            </binding>
          </netTcpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- 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="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <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>


    Client - a consol App

     <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_ISplitService" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:27373/SplitService.svc" binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBinding_ISplitService" contract="SplitService.ISplitService"
                    name="BasicHttpBinding_ISplitService" />
            </client>
        </system.serviceModel>




    Friday, May 31, 2013 2:02 PM

Answers

  • User260886948 posted

    Hi,

    I see that you have do the custom binding with the maxReceivedMessageSize, but the endpoint does not use it.

    First, you need to define a custom basicgttpbinding

     binding configuration with some custom settings:

    <bindings>
      <basicHttpBinding>
        <binding name="CustomLargeSettings"
                 
                maxReceivedMessageSize="2147483647">
            
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

    This above section needs to be in both your server-side's web.config, as well as your client side's config.

    Secondly, on the server-side, you need to have a <services>tag that defines your service and its endpoints and their configuration:

    <services>
       <service name="YourNamespace.YourClassName"
                behaviorConfiguration="ServiceWithMetadata">
          <endpoint name="Default"
                    address="http://localhost:...."
                    binding="basicHttpBinding"
                    bindingConfiguration="CustomLargeSettings"
                    contract="YourNamespace.IServiceContract" />
       </service>
    </services>
    <behaviors>
       <serviceBehaviors>
          <behavior name="ServiceWithMetadata">
             <serviceMetadata httpGetEnabled="true" />
             <serviceDebug includeExceptionDetailInFaults="false" />
          </behavior>
       </serviceBehaviors>
    </behaviors>

    And thirdly, on the client side, you need something like this:

    <client>
      <endpoint name="Default"
                address="http://localhost:...."
                binding="basicHttpBinding"
                bindingConfiguration="CustomLargeSettings"
                contract="ServiceReference.IYourService" />
    </client>

    You need to reference the endpoint defined in your service's definition on the server side, you need to use the same binding and binding configuration, and you need to use the service contract as defined in your service reference.

    Hope it can help you.

    Best Regards,
    Amy Peng 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 2, 2013 11:39 PM

All replies

  • User-488622176 posted

    Please check this : http://www.codeproject.com/Articles/521725/413-Request-Entity-Too-Large

    It appears the SourceDocument is too big to upload.

    Friday, May 31, 2013 5:25 PM
  • User220959680 posted

    missing here .?

    Enable Tracing to troubleshoot the issue. Add below in WCF service configuration and open this trace file using Service Trace Viewer tool.

    <system.diagnostics>
      <sources>
          <source name="System.ServiceModel.MessageLogging"
                   switchValue="Information, ActivityTracing, Error">
            <listeners>
                     <add name="messages"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="messages.svclog" />
              </listeners>
          </source>
        </sources>
    </system.diagnostics>
    
    
    
      <system.serviceModel>
      
        <diagnostics>
        <messageLogging
             logEntireMessage="true"
             logMalformedMessages="true"
             logMessagesAtServiceLevel="true"
             logMessagesAtTransportLevel="true"
             maxMessagesToLog="3000"
             maxSizeOfMessageToLog="2000"/>
      </diagnostics>
    

    Refer http://msdn.microsoft.com/en-us/library/ms732023.aspx

    Sunday, June 2, 2013 5:08 PM
  • User260886948 posted

    Hi,

    I see that you have do the custom binding with the maxReceivedMessageSize, but the endpoint does not use it.

    First, you need to define a custom basicgttpbinding

     binding configuration with some custom settings:

    <bindings>
      <basicHttpBinding>
        <binding name="CustomLargeSettings"
                 
                maxReceivedMessageSize="2147483647">
            
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

    This above section needs to be in both your server-side's web.config, as well as your client side's config.

    Secondly, on the server-side, you need to have a <services>tag that defines your service and its endpoints and their configuration:

    <services>
       <service name="YourNamespace.YourClassName"
                behaviorConfiguration="ServiceWithMetadata">
          <endpoint name="Default"
                    address="http://localhost:...."
                    binding="basicHttpBinding"
                    bindingConfiguration="CustomLargeSettings"
                    contract="YourNamespace.IServiceContract" />
       </service>
    </services>
    <behaviors>
       <serviceBehaviors>
          <behavior name="ServiceWithMetadata">
             <serviceMetadata httpGetEnabled="true" />
             <serviceDebug includeExceptionDetailInFaults="false" />
          </behavior>
       </serviceBehaviors>
    </behaviors>

    And thirdly, on the client side, you need something like this:

    <client>
      <endpoint name="Default"
                address="http://localhost:...."
                binding="basicHttpBinding"
                bindingConfiguration="CustomLargeSettings"
                contract="ServiceReference.IYourService" />
    </client>

    You need to reference the endpoint defined in your service's definition on the server side, you need to use the same binding and binding configuration, and you need to use the service contract as defined in your service reference.

    Hope it can help you.

    Best Regards,
    Amy Peng 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 2, 2013 11:39 PM