wcf service maxUrlLength maxQueryStringLength maxRequestLength

时间:2012-09-19 16:30:05

标签: wcf iis service

你好我有一个WCF服务如果我用超过260个字符变量的路径调用,url会工作吗?有人有什么建议吗?

<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxUrlLength="32766" maxQueryStringLength="2097151" maxRequestLength="2097151" requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true" />
<customErrors mode="Off"/>
 </system.web>
 <system.serviceModel>
<bindings>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- 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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
    <service name="DToolsSynchronizationService.SyncService">
    <endpoint kind="webHttpEndpoint"
    contract="DToolsSynchronizationService.ISyncService" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

我有IIS 7在64位Windows Server 2008中运行runx

我正在打开[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ services \ HTTP \ Parameters]

我右键单击参数选择新的dword 32位值我将其命名为

MaxFieldLength(我选择十六进制)输入fffe,即0x0000fffe(65534)

MaxRequestBytes(我选择十六进制)输入1000000,即0x0000fffe(16777216)

UrlSegmentMaxLength(我选择十六进制)输入fffe,即0x001fffff(2097151)

就像在图片https://dl.dropbox.com/u/541519/fb/reg.png

中一样

我重新启动服务器但仍然只能看到260个字符。我做错了什么

我还打开了iis来设置请求过滤以更正值(查询字符串 - &gt;启用设置2097151以获取最大网址长度,最大查询字符串)

1 个答案:

答案 0 :(得分:-2)

您可以使用自定义webHttpBinding解决此问题。

<bindings>
    <webHttpBinding>
        <binding name="longbinding" maxUrlLength="32766 />
    </webHttpBinding>
</bindings>

然后将其用于您的终端

<endpoint kind="webHttpEndpoint"
    contract="DToolsSynchronizationService.ISyncService" 
    bindingConfiguration="longbinding"/>

您可能需要进一步配置绑定,但这应该是一个开始。