C# WCF:远程服务器返回意外响应:(413)请求实体太大
我的客户端web.config具有:C# WCF:远程服务器返回意外响应:(413)请求实体太大,c#,asp.net-mvc,wcf,web-config,c#-3.0,C#,Asp.net Mvc,Wcf,Web Config,C# 3.0,我的客户端web.config具有: <behaviors> <endpointBehaviors> <behavior name="dataConfiguration"> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavio
<behaviors>
<endpointBehaviors>
<behavior name="dataConfiguration">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISchedulingService" closeTimeout="01:10:00"
openTimeout="00:11:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1234/SchedulingService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISchedulingService"
behaviorConfiguration="dataConfiguration" contract="SchedulingService.ISchedulingService" name="BasicHttpBinding_ISchedulingService" />
</client>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647" executionTimeout="14400"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- increase the size of data that can be serialized -->
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<!-- 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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
即使是200行上传。请导游。谢谢您没有在服务的配置文件中明确定义任何绑定或终结点,因此您将获得一个带有
basicHttpBinding
的默认终结点,其中包含绑定的默认值。请尝试a)在服务配置中定义一个basicHttpBinding
,并将其分配给显式定义的端点,或b)定义一个默认的basicHttpBinding
,该默认值将用于使用该配置文件的所有服务
选项a
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISchedulingService" closeTimeout="01:10:00"
openTimeout="00:11:00" receiveTimeout="01:10:00"
sendTimeout="01:10:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="SchedulingService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISchedulingService"
contract="SchedulingService.ISchedulingService"
name="BasicHttpBinding_ISchedulingService" />
</service>
</services>
即使在200条记录列表中,它仍然抛出相同的错误。。。因此,最后我决定将其分为几部分,而不是立即调用。
感谢您的指导
int chunkSize = 100;
for (var i = 0; i < Details.Count; i += chunkSize)
{
List<List<string>> DetailsChunk = schoolDetails.Skip(i).Take(chunkSize).ToList();
result = scheduleClient.AddDetails(DetailsChunk, savedFileName);
}
int chunkSize=100;
for(变量i=0;i
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISchedulingService" closeTimeout="01:10:00"
openTimeout="00:11:00" receiveTimeout="01:10:00"
sendTimeout="01:10:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="SchedulingService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISchedulingService"
contract="SchedulingService.ISchedulingService"
name="BasicHttpBinding_ISchedulingService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding closeTimeout="01:10:00" openTimeout="00:11:00"
<!-- Remaining binding conifguration snipped for brevity -->
</binding>
</basicHttpBinding>
</bindings>
int chunkSize = 100;
for (var i = 0; i < Details.Count; i += chunkSize)
{
List<List<string>> DetailsChunk = schoolDetails.Skip(i).Take(chunkSize).ToList();
result = scheduleClient.AddDetails(DetailsChunk, savedFileName);
}