2009-07-27 18 views
5

Actualmente tengo un servicio WCF con enlaces webHttp, estoy intentando aumentar el tamaño máximo que se puede ingresar al servicio anulando la configuración predeterminada en config, he intentado hacer algo comoConfiguración del mensaje máximo y el tamaño del búfer para WCF webhttp

<system.serviceModel> 
<bindings> 
<webHttpBinding> 
    <binding name="webHttp" > 
    <security mode="Transport"> 
     <transport clientCredentialType = 
      "None" 
      proxyCredentialType="None" 
      realm="string" /> 
    </security> 
    </binding> 

</webHttpBinding> 
</bindings> 
<services> 

    <service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior"> 
    <!-- Service Endpoints --> 
    <endpoint address="" binding="webHttpBinding" contract="PrimeStreamInfoServices.IService1"> 
     <!-- 
      Upon deployment, the following identity element should be removed or replaced to reflect the 
      identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
      automatically. 
     --> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="PrimeStreamInfoServices.Service1Behavior"> 
     <!-- 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> 
<diagnostics> 

y el establecimiento de varias otras propiedades relacionadas con el tamaño del mensaje, pero ninguno parece estar funcionando, se puede incluso cambiar el tamaño de m ensaje de una vinculación webHttp? ¿Alguna sugerencia? ¡Gracias!

+0

¿Podría publicar la parte correspondiente de su archivo de configuración? –

+0

acaba de editar, compruébalo – Daniel

Respuesta

12

Hay una multitud de ajustes que podrían tener una influencia dependiendo de la configuración - Prueba esto:

<bindings> 
    <webHttpBinding> 
    <binding name="LargeWeb" 
      maxBufferPoolSize="1500000" 
      maxReceivedMessageSize="1500000" 
      maxBufferSize="1500000"> 
     <readerQuotas 
      maxArrayLength="656000" 
      maxBytesPerRead="656000" 
      maxDepth="32" 
      maxNameTableCharCount="656000" 
      maxStringContentLength="656000" 
      /> 
    </binding> 
    </webHttpBinding> 
</bindings> 

Al definir su "versión" de la webHttpBinding y ajustar todos los parámetros a los valores más altos, usted debe estar capaz de atravesar cualquier tamaño de mensaje (casi).

Tenga en cuenta que esto abre su sistema al potencial de ser inundado con mensajes enormes y así caer de rodillas (clásicos ataques de denegación de servicio) - esa es la razón por la que estos límites son bastante bajos - por diseño y a propósito.

Puede cambiarlos a valores más altos; ¡solo tenga en cuenta lo que está haciendo y cuáles son los riesgos de seguridad, si lo hace!

Marc

PS: Con el fin de hacer uso de estos ajustes, por supuesto, hay que hacer referencia a que la configuración de enlace en su servidor y del lado del cliente configuraciones:

<client> 
    <endpoint address="http://localhost" 
      binding="webHttpBinding" bindingConfiguration="LargeWeb" 
      contract="IMyService" /> 
</client> 
<services> 
    <service> 
    <endpoint address="http://localhost" 
       binding="webHttpBinding" bindingConfiguration="LargeWeb" 
       contract="IMyService" /> 
    </service> 
</services> 
+0

Esto no funciona, no me deja enviar algo más grande que 64k todavía – Daniel

+0

¿Puedes mostrar tu configuración? ¿Ha hecho referencia a esta configuración de enlace? –

+0

Sí, me di cuenta de que este era mi problema, solo agregué toda la configuración, aunque cuando puse el atributo bindingCOnfiguration, recibí una excepción, por alguna razón, – Daniel

0

Configuración máxima de los mensajes y el tamaño de búfer para los servicios WCF Rest webhttpbinding

<bindings> 
    <webHttpBinding> 
    <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/> 
    </binding> 
    </webHttpBinding> 
</bindings> 
Cuestiones relacionadas