Impostazione Max Messaggio e buffer di dimensione per WCF webhttp
Domanda
Al momento ho un servizio WCF con attacchi webHttp, im cercando di aumentare la dimensione massima che possono essere immessi a servizio sovrascrivendo le impostazioni predefinite di configurazione, ho provato a fare qualcosa di simile
<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>
e impostando varie altre proprietà di pertinenza di dimensione del messaggio ma nessuno sembra funzionare, si può anche cambiare la dimensione m essaggio di un webHttp vincolante? Eventuali suggerimenti? Grazie!
Soluzione
C'è un gran numero di impostazioni che potrebbero avere un'influenza a seconda delle impostazioni - provate questo:
<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>
Con la definizione di vostra "versione" del webHttpBinding e impostare tutti i parametri ai valori più alti, si dovrebbe essere in grado di ottenere attraverso qualsiasi dimensione messaggi (quasi).
Mente voi: questo non fa aprire il sistema per il potenziale di essere inondato di messaggi enormi e quindi essere portato giù in ginocchio (attacchi classici denial-of-service) - questa è la ragione per cui questi limiti sono fissati piuttosto basso - per design e di proposito.
Si possono cambiare i valori più alti - solo essere consapevoli che cosa state facendo e quali sono i rischi per la sicurezza sono, se si fa
!Marc
PS: Al fine di fare uso di queste impostazioni, è naturalmente necessario fare riferimento a tale configurazione vincolante nei vostri server e lato client configurazioni:
<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>
Altri suggerimenti
Impostazione Max Messaggio e dimensione del buffer per WCF servizi REST webHttpBinding
<bindings>
<webHttpBinding>
<binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
</binding>
</webHttpBinding>
</bindings>