locked
WCF Service -- BizTalk Service -- HTTP/1.1 413 Request Entity Too Large RRS feed

  • Question

  • Hi, I have published a BizTalk WCF service (Schema as a WCF Service). But Later from some reason, the customer  wants a specific port name in the wsdl file - 

    Inorder to make the port name as they want, I have created a .net WCF service. This WCF service will just get the message and sends to the BizTalk WCF service, then gets the response back and sends that to the customer.

    However currently i am getting an error  HTTP/1.1 413 Request Entity Too Large. Whenever a message of more than 65KB size is sent, this error is occurring. However when i directly sent the similar message to the BizTalk WCF Service, It receives and responds fine as i increased maximum received message size in Receive Location. But from .Net WCF service which is created by consuming/adding the BizTalk service as servicereference is not able to receive this message.

    I tried modifying the web.config as mentioned in so many suggestions but nothing works out. Some suggesting i have to modify the Services configuration of BizTalk service as well. But not exactly getting What to change in BizTalk WCF service to make my .Net service works. or the issue lies only in the .Net WCF service ? 

    This is how my .Net Web.Config looks now.

    <?xml version="1.0"?>
    <configuration>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation targetFramework="4.5" />
        <httpRuntime maxRequestLength="2097152" executionTimeout="120" targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_ITwoWayAsync" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00">
              <security mode="Transport">
                <transport clientCredentialType="None" />
              </security>
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://mastercc1.mcc.ad.com:70/MCCBizTalkService/MCCBizTalkReqResp.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITwoWayAsync"
            contract="MCCSvc.MCCBizTalkReqResp" name="BasicHttpBinding_ITwoWayAsync" />
        </client>
        <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>
    
    </configuration>
    

    BizTalk Web.Config

    <?xml version="1.0" encoding="utf-8"?>
    <!-- 
        Note: As an alternative to hand editing this file you can use the 
        web admin tool to configure settings for your application. Use
        the Website->Asp.Net Configuration option in Visual Studio.
        A full list of settings and comments can be found in 
        machine.config.comments usually located in 
        \Windows\Microsoft.Net\Framework\v2.x\Config 
    -->
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <!--
        The <configSections> section declares handlers for custom configuration sections.
      -->
      <configSections>
        <section name="bizTalkSettings" type="Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkConfigurationSection, Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </configSections>
      <!--
        The <bizTalkSettings> section specifies BizTalk specific configuration.
      -->
      <bizTalkSettings>
        <!--
          mexServiceHostFactory debug:
          Set to "true" to launch debugger when MexServiceHostFactory.CreateServiceHost(...) is called by IIS.
          Used to debug from initial point of activation by IIS.
          Default value is "false" for normal operation.
        -->
        <mexServiceHostFactory debug="false">
          <receiveLocationMappings>
            <!--add markupFileName="*.svc" receiveLocationName="?" publicBaseAddress="protocol://host[:port]" /-->
          </receiveLocationMappings>
        </mexServiceHostFactory>
        <!--
          webServiceHostFactory debug:
          Set to "true" to launch debugger when WebServiceHostFactory.CreateServiceHost(...) is called by IIS.
          Used to debug from initial point of activation by IIS.
          Default value is "false" for normal operation.
        -->
        <webServiceHostFactory debug="false" />
        <!--
          isolatedReceiver disable:
          Set to "true" to skip IBTTransportProxy.RegisterIsolatedReceiver(...) and IBTTransportProxy.TerminateIsolatedReceiver(...) calls.
          Used for testing metadata exchange without having to setup receive location.
          Default value is "false" for normal operation.
        -->
        <isolatedReceiver disable="false" />
        <!--
          btsWsdlExporter disable:
          Set to "true" to skip adding BtsWsdlExporter behavior extension to service endpoint.
          Used for testing or comparing strongly-typed WSDL customization versus weakly-typed WSDL of generic WCF service.
          Default value is "false" for normal operation.
        -->
        <btsWsdlExporter disable="false" />
      </bizTalkSettings>
      <appSettings />
      <connectionStrings />
      <system.web>
        <!-- 
          Set compilation debug="true" to insert debugging symbols into the compiled page.
          Because this affects performance, set this value to true only during development.
        -->
        <compilation defaultLanguage="c#" debug="false">
          <assemblies>
            <add assembly="mscorlib, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" />
            <add assembly="Microsoft.BizTalk.Adapter.Wcf.Common, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            <add assembly="Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </assemblies>
        </compilation>
        <!--
          The <authentication> section enables configuration of the security authentication mode
          used by ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows" />
        <!--
          The <customErrors> section enables configuration of what to do if/when an unhandled error
          occurs during the execution of a request. Specifically, it enables developers to configure
          html error pages to be displayed in place of a error stack trace.
        -->
        <!--
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
          <error statusCode="403" redirect="NoAccess.htm" />
          <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
      </system.web>
      <!--
        The <system.serviceModel> section specifies Windows Communication Foundation (WCF) configuration.
      -->
      <system.serviceModel>
        <!--<extensions><behaviorExtensions><add name="btsWsdlExporter" type="Microsoft.BizTalk.Adapter.Wcf.Metadata.BtsWsdlExporterElement, Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /></behaviorExtensions></extensions>-->
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehaviorConfiguration">
              <serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" />
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
            </behavior>
          </serviceBehaviors>
          <!--<endpointBehaviors><behavior name="sharedSecretClientCredentials"><transportClientEndpointBehavior credentialType="SharedSecret"><clientCredentials><sharedSecret issuerName="owner" issuerSecret="ABCD" /></clientCredentials></transportClientEndpointBehavior><serviceRegistrySettings discoveryMode="Public" /><btsWsdlExporter btsServiceDescriptionLocation="ServiceDescription.xml" debug="false" isRelay="false" /></behavior><behavior name="sharedSecretClientCredentialsMex"><transportClientEndpointBehavior credentialType="SharedSecret"><clientCredentials><sharedSecret issuerName="owner" issuerSecret="ABCD" /></clientCredentials></transportClientEndpointBehavior><serviceRegistrySettings discoveryMode="Public" /></behavior></endpointBehaviors>-->
        </behaviors>
        <services>
          <!-- Note: the service name must match the configuration name for the service implementation. -->
          <service name="Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkServiceInstance" behaviorConfiguration="ServiceBehaviorConfiguration">
            <!--<endpoint name="HttpMexEndpoint" address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />-->
            <!--<endpoint name="HttpsMexEndpoint" address="mex" binding="mexHttpsBinding" bindingConfiguration="" contract="IMetadataExchange" />-->
            <!--<endpoint name="RelayEndpoint" address="sb://test01.servicebus.windows.net/EchoServiceNetTcp/" binding="netTcpRelayBinding" bindingNamespace="http://tempuri.org/" bindingConfiguration="RelayEndpointConfig" behaviorConfiguration="sharedSecretClientCredentials" contract="Microsoft.BizTalk.Adapter.Wcf.Runtime.ITwoWayAsyncVoid" />-->
            <!--<endpoint name="MexEndpoint" address="https://test01.servicebus.windows.net/EchoServiceNetTcp/Mex" binding="ws2007HttpRelayBinding" bindingNamespace="http://tempuri.org/" bindingConfiguration="RelayEndpointConfigMex" behaviorConfiguration="sharedSecretClientCredentialsMex" contract="IMetadataExchange" />-->
          </service>
        </services>
      </system.serviceModel>
        <system.webServer>
            <directoryBrowse enabled="true" />
        </system.webServer>
    </configuration>

    Following are the links, I have referred. Any help?

    CodeProject - Request-Entity-Too-Large 

    maxreceivedmessagesize-not-fixing-413-request-entity-too-large

    large-file-upload-failure-for-web-application-calling-wcf-service-413-request-entity-too-large/

    Thursday, October 6, 2016 12:48 AM

Answers

  • Hello,

    You can refer an old thread: Cannot consume WCF service. (413) Request Entity Too Large

    Try removing named binding configuration and use the default one.

    Try below settings:

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

    Also Check IIS uploadreadaheadsize and set to 204800

    cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 204800


    Rachit Sikroria (Microsoft Azure MVP)

    Thursday, October 6, 2016 2:42 AM
    Moderator

All replies

  • The Net Web.Config has max message size has reader quotas applied for the client binding named BasicHttpBinding_ITwoWayAsync, which is the configuration used by your service when acting as the client to the biz talk wcf service.

    You need to set up the reader quotes for the WCF service for it service contract so that when the WCF service receives the message it accepts large messages.  

    Thursday, October 6, 2016 1:53 AM
  • Hi btsadmin

    First check what lanax has already suggested.

    Your request could also get blocked at the IIS virtual directory level for the new WCF service. 

    Refer the troubleshooting steps here for that-

    1. Check IIS Request filtering

    2. Check “UploadReadAheadSize” in IIS

    https://blogs.msdn.microsoft.com/dsnotes/2015/08/21/large-file-upload-failure-for-web-application-calling-wcf-service-413-request-entity-too-large/

    If changing the above does not help, I would suggest you collect WCF traces to gather more information.


    Thanks Arindam



    Thursday, October 6, 2016 2:34 AM
    Moderator
  • Hello,

    You can refer an old thread: Cannot consume WCF service. (413) Request Entity Too Large

    Try removing named binding configuration and use the default one.

    Try below settings:

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

    Also Check IIS uploadreadaheadsize and set to 204800

    cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 204800


    Rachit Sikroria (Microsoft Azure MVP)

    Thursday, October 6, 2016 2:42 AM
    Moderator
  • Thank you very much for all your reply.

    I have modified the web.config as Rachit suggested, and it worked !

    Thursday, October 6, 2016 8:28 AM