Pergunta

Actualmente tenho um serviço WCF com ligações webHttp, im tentando aumentar o tamanho máximo que pode ser introduzido ao serviço, substituindo as configurações padrão na configuração, eu tentei fazer algo parecido

  <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 definir várias outras propriedades pertencentes ao tamanho da mensagem, mas nenhuma parece estar funcionando, pode mesmo mudar o tamanho ENSAGEM m de uma ligação webHttp? Alguma sugestão? Obrigado!

Foi útil?

Solução

Há uma infinidade de definições que podem ter uma influência dependendo de suas configurações - tente o seguinte:

<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>

Ao definir a sua "versão" do webHttpBinding e definir todos os parâmetros para valores mais elevados, você deve ser capaz de obter através de qualquer tamanho de mensagem (quase).

Lembre-se: este não abrir seu sistema para o potencial de ser inundado com mensagens enormes e, portanto, ser trazido para baixo a seus joelhos (clássicos ataques de negação de serviço) - essa é a razão estes limites são definidos bastante baixo - por projetar e de propósito.

Você pode mudá-los para valores mais elevados - basta estar ciente de que você está fazendo e quais são os riscos de segurança, se você fizer

Marc

PS: A fim de fazer uso dessas configurações, você obviamente tem que referência que a configuração obrigatório em todos os seus configurações do lado do cliente e servidor:

<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>

Outras dicas

Configuração Max mensagem e tamanho do buffer para os serviços WCF de descanso WebHttpBinding

<bindings>
  <webHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
    </binding>
  </webHttpBinding>
</bindings>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top