我正在尝试为我的 wcf odata 服务增加 maxReceivedMessageSize。我有另一个 Web 服务将值发布到我的 wcf 服务以将值插入 sql。我在发帖
{
A:1,
B:1,
C:3,
D:4,
}
这引发了一个错误。远程服务器返回错误:(400) 错误请求。如果我发布下面的值,它插入成功。
{
A:1
}
那么有人可以帮我解决这个错误吗?网上有一些例子试图修改下面的网络配置,但它们不适合我,因为我没有服务合同。
<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>
我的 WCF 使用 ADO.net 实体模型
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;
}
}