I am trying to increase maxReceivedMessageSize for my wcf odata service. I have an another web service which is posting values to my wcf service to insert values to sql. I am posting
{
A:1,
B:1,
C:3,
D:4,
}
this raised an error. The remote server returned an error: (400) Bad Request. If i post the value below, it inserted successfully.
{
A:1
}
so can somebody please help me how to fix this error please? There are examples on the web which are trying to modify web config like below but they dont suits me because i dont have a service contract.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- Create a custom binding for our service to enable sending large amount of data -->
<binding name="MyBasicHttpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<!-- Enable the serializer to serialize greater number of records -->
<behavior name="WCFServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<!-- Bind the WCF service to our custom binding -->
<service behaviorConfiguration="WCFServiceBehavior"
name="WcfDataService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract=" `WHICH I DONT HAVE, OR I HAVE IT BUT I AM NOOB` "/>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
My WCF working with ADO.net Entity Model
public class WcfDataService : DataService< DataModel.DataModelEntities >
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("*", EntitySetRights.All);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
Contract is System.Data.Services.IRequestHandler from Microsoft.Data.Services.
My configuration:
<system.serviceModel>
<services>
<service name="ODataSampleRun.DemoDataService" behaviorConfiguration="Behavior">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint contract="System.Data.Services.IRequestHandler" binding="customBinding" bindingConfiguration="RawODataService" address="http://localhost:9090/DemoDataService" behaviorConfiguration="test" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="NoneWebBinding">
<security mode="None" />
</binding>
</webHttpBinding>
<customBinding>
<binding name="RawODataService">
<webMessageEncoding webContentTypeMapperType="ODataSampleRun.RawContentTypeMapper, ODataSampleRun, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="test">
<webHttp faultExceptionEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Behavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>