Reputation: 53
this seems to be a really common question - and I've read through a ton of comments here on SO and other sites. Problem is that even after fixing up my configuration I'm still getting the 413 error when sending an ~50K payload.
Here's the relevant portion of the service config...
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
<services>
<service name="Sync.Inbound" behaviorConfiguration="serviceWebConfiguration">
<endpoint address="" binding="webHttpBinding" bindingName="defaultRest" behaviorConfiguration="web" contract="Sync.IInbound" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="defaultRest" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<behavior name="json">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceWebConfiguration">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
I'm testing by calling this from a simple C# console application via an httpWebRequest... Anybody see anything I'm missing in the service config?
Upvotes: 1
Views: 472
Reputation: 7067
You need to set the bindingConfiguration
attribute to "defaultRest"
on the service endpoint element, otherwise the service will not use the specified binding configuration block.
The sample above shows the binding configuration name in a "bindingName" attribute rather than the "bindingConfiguration" attribute. Therefore, you need to change:
<endpoint ... bindingName="defaultRest"
to:
<endpoint ... bindingConfiguration="defaultRest"
Example:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
<services>
<service name="Sync.Inbound" behaviorConfiguration="serviceWebConfiguration">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="defaultRest" ...
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="defaultRest" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
Reference:
https://msdn.microsoft.com/en-us/library/ms733099(v=vs.110).aspx
bindingConfiguration vs bindingName
Upvotes: 1
Reputation: 15175
You might want to change up maxItemsInObjectGraph
for your services dataContractSerializer
to allow larger collections through.
<serviceBehaviors>
<behavior name="SecureServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647"/>
<serviceTimeouts transactionTimeout="00:03:00"/>
<serviceThrottling maxConcurrentCalls="10" maxConcurrentSessions="10" maxConcurrentInstances="10"/>
</behavior>
</serviceBehaviors>
Upvotes: 0