#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" />
</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>
И HostApp web.config имеет :
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="dataConfiguration">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing m7tadata 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>
И ServiceApp web.config имеет :
<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>
Теперь,
В моем методе контроллера в клиенте я попытался перейти к службе
* Список из 3600 строк [] для обслуживания
и
* Вместо этого строка из 3600 строк, разделенных разделителем (таблица анализа Excel)
(PS: для каждой строки есть 12 строковых значений (а общее количество строк = 3600))
Но я продолжаю получать :
The remote server returned an unexpected response: (413) Request Entity Too Large.
Даже для загрузки 200 строк.
Пожалуйста, укажите. Спасибо
Ответ №1:
У вас нет никаких привязок или конечных точек, явно определенных в файле конфигурации службы, поэтому вы получаете конечную точку по умолчанию со basicHttpBinding
значениями по умолчанию для привязки. Попробуйте либо а) определить a basicHttpBinding
в конфигурации службы и назначить его явно определенной конечной точке, либо б) определить значение по умолчанию 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>
В приведенной выше конфигурации a basicHttpBinding
определяется с именем «BasicHttpBinding_ISchedulingService», и это определение присваивается конечной точке службы через bindingConfiguration
атрибут <endpoint>
элемента.
Вариант b
Аналогично варианту a выше, за исключением того, что раздел конфигурации привязки опускает name
атрибут, и конечная точка службы не определена. Определенная конфигурация привязки будет использоваться для всех служб, которые используют basicHttpBinding
, если она не переопределена для явно определенной конечной точки через bindingConfiguration
атрибут.
<bindings>
<basicHttpBinding>
<binding closeTimeout="01:10:00" openTimeout="00:11:00"
<!-- Remaining binding conifguration snipped for brevity -->
</binding>
</basicHttpBinding>
</bindings>
Ответ №2:
Он по-прежнему выдавал ту же ошибку даже для списка 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);
}