Pregunta

Estoy tratando de cargar archivos usando WCF. Todo menos de 16k funciona bien, pero cualquier cosa sobre este error:

Hubo un error que deserializaba el objeto del sistema de tipos. Byte []. La cuota de longitud de matriz máxima (16384) se ha excedido mientras se lee los datos XML. Esta cuota puede aumentarse cambiando la propiedad MaxArrayLength en el objeto XMLDICCIONARYRERECERQUETAS utilizado al crear el lector XML

Este es mi servicio WCF App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IRAISAPI" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="RAIS_WCF_Services.RAISAPI">
        <endpoint address="" binding="wsHttpBinding" contract="RAIS_WCF_Services.IRAISAPI">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/RAIS_WCF_Services/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

y aquí está mi cliente App.Config

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IRAISAPI" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/RAIS_WCF_Services/Service1/"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRAISAPI"
        contract="RAIS.IRAISAPI" name="WSHttpBinding_IRAISAPI">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

¡Cualquier ayuda es muy apreciada! Gracias.

¿Fue útil?

Solución

No parece que su servicio no se refiera correctamente a su configuración de enlace.

Busque en su servicio de configuración para wshttpbinding_iraisapi y verá a qué me refiero.

Necesitas:

    <endpoint address="" binding="wsHttpBinding" 
              contract="RAIS_WCF_Services.IRAISAPI"  
              bindingConfiguration="WSHttpBinding_IRAISAPI">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

Otros consejos

Supongo que quiere decir que la configuración MaxArrayLength no se está configurando automáticamente en la configuración de su cliente después de agregar una referencia de servicio y/o se está perdiendo después de actualizar la referencia de servicio de su cliente. Si esto es lo que estás experimentando, esto es por diseño. Las configuraciones como Tiempos de espera, MaxArrayLength, etc. no están expuestas en WSDL y, por lo tanto, el Servicio no puede empujar al cliente cuando se crea/actualiza la referencia del servicio.

Intenta agregar esto configuración global a su configuración del lado del servidor. Esto vinculará su servicio vinculante a una configuración vinculante.

<system.serviceModel>
    <protocolMapping>
      <remove scheme="http"/>
      <add scheme="http" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRAISAPI" />
    </protocolMapping>
</system.serviceModel>

También puedes usar behaviors/serviceBehaviors/behavior/serviceMetadata/httpGetBindingConfiguration para una solución más localizada.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top