locked
Cannot consume WCF service. (413) Request Entity Too Large RRS feed

  • Question

  • Hi,

    I have a WCF Service which I consume in BizTalk. I have had this working previously but now after recent deploys, it is failing. When BizTalk tries to send a message to the WCF service, I get the error:

    The adapter failed to transmit message going to send port "WcfSendPort_TradacomsSalesOrder_BasicHttpBinding_ITradacomsSalesOrder" with URL "http://024354pc/XMLFileDesizer.WCF/TradacomsSalesOrder.svc". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large. ---> System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large.


    I have consumed the service by the 'Consume WCF Service' wizard in BizTalk. This gives me a schema, my message types, my port types and my bindings. I have then used XSD to generate a c# class of the generated schema so that I can create a new request message in code and then serialize as the schema type. This is what I always do and it usually works!!

    I have set the MaxRequestedMessageSize property on my endpoint in WCF. The wizard in BizTalk gives me 2 binding files, 1 basicHttpBinding and 1 custom basicHttpBining. I have tried both. I have also set the maxRequestedMessageSize on each. I have also set this property in my orchestration like this:

    msgSplitTradacomsInput(WCF.MaxReceivedMessageSize) = 1000000;

    But, no joy. The really annoying thing is if I create a new BizTalk project and consume the WCF service via the wizard, setting everything up fro fresh, it works! I have tried stripping everything our of my project an generating it again.

    The message that I am sending is a mere 58Kb. 

    I am using BizTalk Server 2006 R2 on Win Xp Pro 32-bit. 

    Here is the full exception with stack trace:

    The adapter failed to transmit message going to send port "WcfSendPort_TradacomsSalesOrder_BasicHttpBinding_ITradacomsSalesOrder" with URL "http://024354pc/XMLFileDesizer.WCF/TradacomsSalesOrder.svc". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large. ---> System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large.
       at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
       --- End of inner exception stack trace ---
    
    Server stack trace: 
       at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)
    
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)".
    
    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    I'd really appreciate any suggestions

    Thanks

    Rod


    • Edited by Rod Hall Tuesday, January 7, 2014 2:10 PM
    Tuesday, January 7, 2014 2:08 PM

Answers

  • Hi Rod ,

    Can you try this one

    <bindings>
          <basicHttpBinding>
            <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>

    Check IIS uploadreadaheadsize and set to 204800

    cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 204800

    and increase max buffer size at send and receive port binding Properties . Restart the IIS and Host instance .

    Thanks

    Abhishek



    Tuesday, January 7, 2014 4:58 PM
  • Thanks again Abhishek you've done it !!

    I had previously set uploadReadAhead and triple checked the port settings. The problem was the binding configuration. I was using a named binding configuration and referencing that in my endpoint. If I take out the names and use the default as you have done, it works!

    This is a real help, thank you 

    • Marked as answer by Rod Hall Wednesday, January 8, 2014 11:02 AM
    Wednesday, January 8, 2014 11:01 AM

All replies

  • Hi Rod,

    You need to set maxReceivedMessageSize in your binding. You can also need to set readerQuotas.

    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding maxReceivedMessageSize="10487760">
            <readerQuotas ... />
          </binding>
        </basicHttpBinding>
      </bindings> 
    </system.serviceModel>

    Thanks

    Abhishek

    Tuesday, January 7, 2014 2:51 PM
  • Thanks for your answer Abhishek but it doesn't fix my problem. I already had the maxReceivedMessageSize set in my binding. I did not have the readerQuotas set but I have just tried and no luck :(

    Here is my WCF Web.Config:

    <?xml version="1.0"?>
    <configuration>
    
      <system.diagnostics>
        <sources>
          <source name="NewSource" switchValue="Warning, ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add type="System.Diagnostics.EventLogTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="NewListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
            <filter type="" />
          </add>
        </sharedListeners>
      </system.diagnostics>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <services>
          <service name="NewServiceType">
            <endpoint address="http://024354pc/XMLFileDesizer.WCF/TradacomsSalesOrder.svc"
              binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_ITradacomsSalesOrder"
              name="" bindingNamespace="http://Bakkavor.XMLFileDesizer.Schemas.TradacomsSalesOrder"
              contract="Bakkavor.XMLFileDesizer.WCF.ITradacomsSalesOrder" />
          </service>
        </services>
        <diagnostics>
          <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
            logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
          <endToEndTracing propagateActivity="true" activityTracing="true"
            messageFlowTracing="true" />
        </diagnostics>
        <bindings>
          <basicHttpBinding>
            <binding name="basicHttpBinding_ITradacomsSalesOrder" maxBufferPoolSize="10487760"
              maxBufferSize="10487760" maxReceivedMessageSize="10487760">
              <readerQuotas maxDepth="10487760" maxStringContentLength="10487760"
                maxArrayLength="10487760" maxBytesPerRead="10487760" maxNameTableCharCount="10487760" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <client/>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
              <serviceMetadata httpGetEnabled="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>
        <serviceHostingEnvironment 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>
    
    </configuration>
    

    Does this look ok?

    Tuesday, January 7, 2014 4:17 PM
  • Tuesday, January 7, 2014 4:35 PM
  • Hi Rod ,

    Can you try this one

    <bindings>
          <basicHttpBinding>
            <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>

    Check IIS uploadreadaheadsize and set to 204800

    cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 204800

    and increase max buffer size at send and receive port binding Properties . Restart the IIS and Host instance .

    Thanks

    Abhishek



    Tuesday, January 7, 2014 4:58 PM
  • Thanks again Abhishek you've done it !!

    I had previously set uploadReadAhead and triple checked the port settings. The problem was the binding configuration. I was using a named binding configuration and referencing that in my endpoint. If I take out the names and use the default as you have done, it works!

    This is a real help, thank you 

    • Marked as answer by Rod Hall Wednesday, January 8, 2014 11:02 AM
    Wednesday, January 8, 2014 11:01 AM
  • Thanks  Rod and Abhishek, this solved the same issue in my application also. However still not clear why name had to be removed ? Would like to hear back if this was  developer mistake or Microsoft issue ?
    Friday, March 13, 2020 10:10 AM