G-Man
G-Man

Reputation: 7241

Post Large amount of JSON data to WCF Service

I am working with a .NET WCF Service, which accepts JSON data as an HTTP Post from another .NET application.

When I post a small amount of data everything works fine ( ~ up to 65kb of data )

however when I try to post more than that, I get an Internal Server error on the service side.

Everything points to the service being limited to accepting up to 65kb worth of data.

I have read about modifying my config file to accept more data with the maxrequestmessagesize attribute, however my problem is that my web.config does not have any bindings that I can see.

Here is what I have in my config file that relates to the service

<system.serviceModel>

    <behaviors>

      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above 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>

I am not sure what to do in order to get past that 65 k limit - Any help would be appreciated.

Thanks

Upvotes: 1

Views: 1496

Answers (2)

Yaqub Ahmad
Yaqub Ahmad

Reputation: 27659

Use this in your config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ImyService"
                maxBufferPoolSize="2147483647"
                maxReceivedMessageSize="2147483647">
            </binding>
        </basicHttpBinding>
    </bindings>

</system.serviceModel>

Upvotes: 2

mikey
mikey

Reputation: 5160

I just took a quick look and I have 4 settings in different places to "raise the request size bar" for my WCF service:

maxarraylength (binding/readerquotas tag) maxbuffersize (binding tag) maxreceivedmessagesize (binding tag) maxrequestlength (system.web/httpruntime tag)

I'm not sure why there are no bindings in your config. Perhaps if not specified, then default values are used? Do you have any services/service/endpoint tags? Perhaps you're setting these via code?

Upvotes: 1

Related Questions