Enviando objeto ao serviço WCF. MaxStringContentLength (8192 bytes) excedido ao desserializar
Criei um serviço Web WCF simples que possui um método: SubmitTicket (flightticket ft, nome de usuário da string, senha da string)
No lado do cliente, tenho um aplicativo para preencher um formulário (uma passagem aérea) e enviá-lo para este serviço da Web recém-criado. Quando este objeto da flightticket excede 8192 bytes, recebo o seguinte erro:
"Ocorreu um erro ao desserializar o objeto do tipo flightticket. A cota máxima de comprimento do conteúdo da string (8192) foi excedida ao ler os dados XML. Essa cota pode ser aumentada alterando a propriedade MaxStringContentLength no objeto XmlDictionaryReaderQuotas usado ao criar o leitor XML "
Fiz uma pesquisa on-line e descobri que preciso definir o MaxStringContentLength no web.config (servidor) e app.config (cliente) para um número maior. O problema é que eu tentei todas as combinações possíveis de configurações nos dois arquivos de configuração, lendo vários blogs e sites, mas AINDA falha no mesmo err
Anexei meu código de configuração de cliente e servidor (como está no momento, ele passou por muitas e muitas mudanças ao longo do dia sem sucesso
Uma coisa que notei é que o arquivo configuration.svcinfo no meu aplicativo cliente parece sempre mostrar 8192 para MaxStringContentLength quando atualizo a referência de serviço. Parece ter todos os valores padrão, mesmo se eu definir explicitamente as propriedades de ligação. Não tenho certeza se isso está relacionado ao meu problema, mas vale a pena mencionar.
Aqui está o código app.config / web.config aplicável para definir as ligações do nó de extremidade:
<<<<< CLIENTE >>>>>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFlightTicketWebService" 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="65536" maxArrayLength="16384"
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://xx.xx.xx/xxxxxxxx.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFlightTicketWebService"
contract="FlightTicketWebService.IFlightTicketWebService"
name="BasicHttpBinding_IFlightTicketWebService" />
</client>
</system.serviceModel>
</configuration>
<<<<< SERVIDOR >>>>>
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="GSH.FlightTicketWebService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<httpRuntime maxRequestLength="16384"/>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFlightTicketWebService" 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="65536" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</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"/>
<services>
<service name="FlightTicketWebService">
<endpoint
name="FlightTicketWebServiceBinding"
address="http://xx.xx.xx/xxxxxxxxxxx.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IFlightTicketWebService"
contract="IFlightTicketWebService"/>
</service>
</services>
</system.serviceModel>
<system.webServer>