Usuário com melhor resposta
Problema com MaxArrayLength

Pergunta
-
Galera,
Preciso de uma ajuda, pois realmente nao sei onde pode estar o problema.
Estou utilizando o Linq to Sql no meu serviço WCF, porém preciso transferir algumas imagens do meu client para o server através de um campo imagem do SQL, ao tentar fazer isso obtenho o seguinte erro:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:User. The InnerException message was 'There was an error deserializing the object of type WcfServiceFuturePMS.Users. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 62365.'. Please see InnerException for more details.
O mais estranho é que já fiz a alteração nessa propriedade e mesmo assim continuo com o mesmo erro.
Respostas
-
Boas Thiago,
O problema é que você deve estar utilizando o IIS para hospedar o serviço, então o endpoint não está configurado no web.config, ou seja, ele não faz uso das configurações que está ali. Se você está utilizando a versão 4.0 do .NET Framework/WCF, então tente o remover o nome do binding, de:
<bindings>
<basicHttpBinding>
<binding name="myBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Para:
<bindings>
<basicHttpBinding>
<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Se não resolver, teremos que tentar outra alternativa.
http://www.israelaece.com- Sugerido como Resposta AndreAlvesLimaModerator terça-feira, 20 de julho de 2010 12:00
- Marcado como Resposta Israel AeceModerator terça-feira, 20 de julho de 2010 14:27
Todas as Respostas
-
Seguem meus arquivos de configuração do WCF.
Server:
<?xml version="1.0"?> <configuration> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Warning, ActivityTracing" propagateActivity="true"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="ServiceModelTraceListener"> <filter type="" /> </add> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="ServiceModelMessageLoggingListener"> <filter type="" /> </add> </listeners> </source> </sources> <sharedListeners> <add initializeData="c:\users\thiago lima\desktop\oficial\futurepms\wcfservicefuturepms\web_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> <filter type="" /> </add> <add initializeData="c:\users\thiago lima\desktop\oficial\futurepms\wcfservicefuturepms\web_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> <filter type="" /> </add> </sharedListeners> <trace autoflush="true" /> </system.diagnostics> <connectionStrings> <add name="FuturePMSConnectionString1" connectionString="Data Source=THIAGO-NOTEBOOK\SQLEXPRESS;Initial Catalog=FuturePMS;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <diagnostics wmiProviderEnabled="true"> <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" /> </diagnostics> <bindings> <basicHttpBinding> <binding name="myBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxArrayLength="2147483647" /> </binding> </basicHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior> <!-- 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="true"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
Client:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IServiceFuturePMS" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:51391/ServiceFuturePMS.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceFuturePMS" contract="WCFServiceFuturePMS.IServiceFuturePMS" name="BasicHttpBinding_IServiceFuturePMS" /> </client> </system.serviceModel> </configuration>
-
- Sugerido como Resposta AndreAlvesLimaModerator segunda-feira, 19 de julho de 2010 19:50
-
-
Boas Thiago,
O problema é que você deve estar utilizando o IIS para hospedar o serviço, então o endpoint não está configurado no web.config, ou seja, ele não faz uso das configurações que está ali. Se você está utilizando a versão 4.0 do .NET Framework/WCF, então tente o remover o nome do binding, de:
<bindings>
<basicHttpBinding>
<binding name="myBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Para:
<bindings>
<basicHttpBinding>
<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Se não resolver, teremos que tentar outra alternativa.
http://www.israelaece.com- Sugerido como Resposta AndreAlvesLimaModerator terça-feira, 20 de julho de 2010 12:00
- Marcado como Resposta Israel AeceModerator terça-feira, 20 de julho de 2010 14:27
-