Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6700813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:51:34+00:00 2026-05-26T06:51:34+00:00

I have a WCF method that accepts arbitrary binary data which the service will

  • 0

I have a WCF method that accepts arbitrary binary data which the service will save to a file on the filesystem. Here is the WCF method:

[OperationContract]
[WebInvoke( Method="PUT", UriTemplate="/products/{productId}/resources/{resourceName}")]
public void PutResource(String productId, String resourceName, Stream resource)

However whenever my clients (a WinForms HttpWebRequest contraption) attempt to make this request the system (either IIS or WCF or something in the chain) responds with HTTP 400 Bad Request with an empty body (the content-length is set to zero anyway). I set a breakpoint on my WCF method and the method is never called, in fact I get the same error when I call the same URI with the method commented out entirely.

I set another breakpoint in my ProvideFault method in my IErrorHandler class, but that is never called, which suggests something is going wrong before WCF is invoked.

I just tried the method again, but with a smaller request resource (a text stream, 3 bytes long) and that actually worked fine, it seems whenever I use anything larger than a few kilobytes it fails.

I can’t think of what to change to get this to work – any suggestions?

EDIT: I’m using the WCF REST Starter Kit 2, which uses CustomBinding under the hood which doesn’t seem to use the MaxReceivedMessageSize property (and the default to that is 65536, but my method fails with requests over a few KB).

EDIT2: It seems after rebuilding my project and testing a variety of files, that the limit is actually 64KB. Now to find out where that 64KB limit is being specified…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:51:34+00:00Added an answer on May 26, 2026 at 6:51 am

    I solved it. Here’s the code I added to my WebServiceHost2 subclass to fix the problem:

    protected override void OnOpening() {
        base.OnOpening();
    
        foreach(ServiceEndpoint ep in base.Description.Endpoints) {
    
            if( ep.Binding is CustomBinding ) {
    
                CustomBinding cb = (CustomBinding)ep.Binding;
    
                foreach(BindingElement e in cb.Elements) {
    
                    if( e is HttpTransportBindingElement ) {
    
                        HttpTransportBindingElement h = (HttpTransportBindingElement)e;
                        h.MaxReceivedMessageSize = Int32.MaxValue; // "2GB should be enough for anyone".
                    }
    
                }
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I want to create a WCF service that have login method, which is
I have a WCF service which exposes a method that returns an array of
I have a WCF service method that accepts a List of objects. For this
I have a WCF service method that expects an object and then retrieves its
I have a WCF service method that's running in a worker thread I spin
I have a basicHttpBinding WCF service. Via the contract I expose a method that
I have a WCF Service that exposes a method GetCustomers(). The internals of the
Let's say I have a WCF service which has a method returning object Person.
I have a WCF service that accepts an object as a parameter that has
I have a WCF service that accepts requests from JQuery. Currently, I can access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.