yves
yves

Reputation: 21

WCF Service -> max

Looks like this question has been asked thousand times already, but each person's configuration problems are different. I have WCF server that serves images and also receives upload image requests. When uploading images I'm getting error 400 when size is more then 65k.

I turned the trace on the WCF and I'm getting exact error

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

I know that I need to increase this parameters but I'm just can find where is it supposed to be in my web.config file. Here is what I have in web.config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
          openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647"
          textEncoding="utf-8"
          transferMode="Streamed">
          <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="ESLMobileIhaServiceClient.ServiceMobileIha" behaviorConfiguration="returnFaults">
        <endpoint contract="ESLMobileIhaServiceClient.ServiceMobileIha" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"/>
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex">
        </endpoint>
      </service>
    </services>
    </system.serviceModel>
  <system.webServer>

Anyone here whih can help me out with this? ;) trying since 4 hours with different approaches found on stackoverflow but nothing helps - unfortunatelly.

UPDATE:

the request is an upload of a file from client TO server. The error appears in the servers logfile when enabled diagnostics.

SERVER Web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
          openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647"
          textEncoding="utf-8"
          transferMode="Streamed">
          <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="ESLMobileIhaServiceClient.ServiceMobileIha" behaviorConfiguration="returnFaults">
        <endpoint contract="ESLMobileIhaServiceClient.ServiceMobileIha" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"/>
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex">
        </endpoint>
      </service>
    </services>
    </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

Client App.config

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="InputFileLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\Stammdaten\"/>
    <add key="OutputFileLocationOpen" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\offen\"/>
    <add key="OutputFileLocationClosed" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\abgeschlossen\"/>
    <add key="ImageObserveLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\kamerabilder\"/>
    <add key="ImageSaveLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\savedimages\"/>
    <add key="DeleteImageAfterCopy" value="true"/>
    <add key="HelpFile_de_DE" value="ESL_EVU_1031_Mobile_Instandhaltung.pdf"/>
    <add key="HelpFile_fr_FR" value=""/>
    <add key="BackupLocation" value="backup\"/>
    <add key="NumOfBackups" value="3"/>
    <add key="Language" value="de_DE"/>
    <add key="FontType" value="Arial"/>
    <add key="TextSize" value="10"/>
    <add key="TitleTextSize" value="12"/>
    <add key="ButtonTextSize" value="12"/>
    <add key="IdentifikationGeraet" value="Kontrolle/Instandhaltung"/>
    <add key="ClientSettingsProvider.ServiceUri" value=""/>
  </appSettings>
  <system.web>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
      </providers>
    </roleManager>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ServiceMobileIha" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:51515/ServiceMobileIha.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ServiceMobileIha"
        contract="ServiceReference1.ServiceMobileIha" name="BasicHttpBinding_ServiceMobileIha" />
    </client>
  </system.serviceModel>

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Upvotes: 1

Views: 965

Answers (3)

yves
yves

Reputation: 21

replace:

  <system.web>
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>

with

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>

to allow overall httpRuntime -> maxRequestLenght increase ;)

have a nice weekend guys

Upvotes: 1

Rich
Rich

Reputation: 2096

This does affect specifically the maxReceivedMessageSize configuration, but it could be client or server. Because the client is receiving the reply, but the server is receiving the request. So it depends which one is too big. For example, if the client is sending the big payload, but the server is sending back void or a bool or something small, it's the server's config that has to change, and vice versa.

Upvotes: 0

Harry89pl
Harry89pl

Reputation: 2435

It's can be problem of client side. Did you change maxReceivedMessageSize , maxBufferPoolSize and maxBufferSize on your client side?

Upvotes: 0

Related Questions