내가 처리하려고하는이 미친 문제가 있습니다. 엄청난 양의 데이터를 가져올 때 클라이언트 .config 파일의 할당량을 늘려야하지만 클라이언트가 WCF 서버에 거대한 데이터를 보내는 경우 어떻게해야할까요?들어오는 메시지의 최대 메시지 크기 할당량 (65536) .... 할당량을 늘리려면 MaxReceivedMessageSize 속성을 사용하십시오.
작은 크기의 입력 매개 변수를 보내면 정상적으로 작동합니다. 불행히도 입력이 커지면 분해됩니다.
디버거는 말한다 :
잘못된 요청, 400;
추적 파일에는 다음과 같습니다 수신 메시지 (65536)에 대한
최대 메시지 크기 할당량 초과했습니다. 할당량을 늘리려면 적절한 바인딩 요소에 MaxReceivedMessageSize 속성을 사용합니다.
서버 쪽에서 데이터를 가져 오는이 할당량을 늘릴 수있는 방법이 있습니까? 그렇다면 어떻게?
여기 내 샘플 설정 관련이 부품 : 여기
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64" 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="MyWcfService">
<endpoint address="http://myservice..."
binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding"
name="MyBasicHttpBinding" contract="IMyContract" />
</service>
</services>
및 내 클라이언트 측 코드입니다 (나는 동적으로 생성) :
이 var binding = new BasicHttpBinding();
binding.MaxBufferPoolSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxDepth = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
var address = new EndpointAddress("http://mylocalservice..");
ChannelFactory<IMyContract> factory = new ChannelFactory<IMyContract>(binding, address);
foreach (OperationDescription op in factory.Endpoint.Contract.Operations)
{
DataContractSerializerOperationBehavior dataContractBehavior =
op.Behaviors.Find<DataContractSerializerOperationBehavior>()
as DataContractSerializerOperationBehavior;
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = 2147483646;
}
}
public IMyContract MyClientObject = factory.CreateChannel();
난 [여기] 한 단계에서 문제를 해결 [1] [1]에 http : // 유래.com/questions/7476853/wcf-error-maximum-of-so-serialize 또는 deserialized-in-an/8656402 # 8656402 – Ram
클라이언트 측 코드에서 코드를 통해 readerquotas를 설정합니다. 그래서 아래에 그것들을 설정하는 접근법이 있습니다 : XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas(); myReaderQuotas.MaxStringContentLength = 2147483647; myReaderQuotas.MaxArrayLength = 2147483647; myReaderQuotas.MaxBytesPerRead = 2147483647; myReaderQuotas.MaxDepth = 64; myReaderQuotas.MaxNameTableCharCount = 2147483647; binding.GetType(). GetProperty ("ReaderQuotas"). SetValue (binding, myReaderQuotas, null); – Rajesh