如何将httpRuntime maxRequestLength =“8096”集成到app.config [Webservices]

时间:2012-06-04 13:51:45

标签: .net web-services

我有一个等待xml到达的web服务。今天我们注意到,XML有时似乎太大了。现在我想将<httpRuntime maxRequestLength="10096" useFullyQualifiedRedirectUrl="true" executionTimeout="120"/>添加到我的app.config中。不幸的是它似乎没有效果......这是我的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <httpRuntime maxRequestLength="10096"
        useFullyQualifiedRedirectUrl="true"
        executionTimeout="120"/>
  </system.web>

  <system.serviceModel>
    <client />
    <standardEndpoints />
    <services>
      <service behaviorConfiguration="metadataSupport" name="iib.wohnpreis.wohnpreisserver">
        <host>
          <baseAddresses>
            <add baseAddress="URLToWebservice" />
          </baseAddresses>
        </host>
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" transferMode="Buffered" useDefaultWebProxy="false">
          <readerQuotas maxStringContentLength="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataSupport">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="wohnpreis/mex" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

任何建议出了什么问题? 谢谢你试图帮助我!

斯特芬

1 个答案:

答案 0 :(得分:2)

遇到了问题。服务器告诉客户端maxStringContentLength被限制为8096 - 这不是真的,因为我们用

定义了它
<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding" transferMode="Buffered" useDefaultWebProxy="false">
      <readerQuotas maxStringContentLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

不幸的是,这只有在我们删除name="basicHttpBinding"所以它看起来像

时才有效
<bindings>
  <basicHttpBinding>
    <binding transferMode="Buffered" useDefaultWebProxy="false">
      <readerQuotas maxStringContentLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

不知道名称是如何干扰配置的 - 但没有名称它可以正常工作......