0

When I upload a photo from my WP7 to my WCF web service I get '413 Request Entity Too Large', and no matter what I do, I cannot stop it from happening.

My binding information for the web service is:

<bindings>
  <basicHttpBinding>
    <binding name="uploadfilebinding" closeTimeout="10:01:00"
      maxBufferSize="2147483646" maxBufferPoolSize="2147483646"
      maxReceivedMessageSize="2147483646" openTimeout="10:01:00"
      receiveTimeout="10:10:00" sendTimeout="10:01:00"
      messageEncoding="Mtom" transferMode="StreamedRequest">
      <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
                    maxArrayLength="2147483646" maxBytesPerRead="2147483646"
                    maxNameTableCharCount="2147483646" />
    </binding>
  </basicHttpBinding>
</bindings>

As you can see I have set maxReceivedMessageSize to the highest I can, but to no avail, Can anyone help me please?

My server is 'Windows Server 2008 R2 Standard' and the service is running under .NET 4.

Thanks in advance,

Lee

P.S. If you need anymore information, please ask and I'll post it.

Thanks for the replies:

As this is a WP7 app, the client configuration file is a hidden file called 'ServiceReferences.ClientConfig' that is created by the service, and the binding in there is now:

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IMbcSync" closeTimeout="10:01:00"
      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" openTimeout="10:01:00"
      receiveTimeout="10:10:00" sendTimeout="10:01:00"
      transferMode="StreamedResponse">
    </binding>
  </basicHttpBinding>
</bindings>

But I'm still getting the same error. Any more suggestions would be much appreciated?

Lee

Leeb65
  • 23
  • 1
  • 7

1 Answers1

3

There are multiple places that you may increase to the maximum possible size. Some of them are WCF related and some of them are IIS related. In addition to the options mentioned in the comments, try to increase the followings (maxRequestLength, and maxAllowedContentLength) in your config file on the server side to take care of the IIS side too:

<system.web>
  <httpRuntime maxRequestLength="2147483647" useFullyQualifiedRedirectUrl="true"   executionTimeout="14400"/>
</system.web>

  <system.webServer>
   <modules runAllManagedModulesForAllRequests="true"/>
    <security>
     <requestFiltering allowDoubleEscaping="true">
      <requestLimits maxAllowedContentLength="2147483647"/>
      <fileExtensions allowUnlisted="true"/>
      <verbs allowUnlisted="true"/>
     </requestFiltering>
    </security>
  </system.webServer>
Wizact
  • 161
  • 5
  • Thanks Wizact! I basically copied the above into the web.config and placed it on the server (after checking it was all working), but the same error when I take a photo and click save, the photo is never on the server. I wonder if it would be a good idea to scale the image down. – Leeb65 Apr 27 '13 at 06:46
  • I assume based on your comment that the message size issue fixed. Remember that you are sending the picture as a stream (transferMode) so by just calling the property name on the server you cannot get the stream (It is empty). You need to read the stream and write it to a memory stream and then save it. Refer to this for streaming https://gist.github.com/wizact/5492446 – Wizact Apr 30 '13 at 22:31
  • The server side saves small pictures without a problem when I use the Windows Phone emulator. As you probably know, the images are nothing more than a white background with a small black box or similar then. It's when I try to upload a real photo from my phone it fails. – Leeb65 May 02 '13 at 08:46