WCF URL长度导致IIS 400错误请求错误 [英] WCF URL Length Causing IIS 400 Bad Request Error

查看:137
本文介绍了WCF URL长度导致IIS 400错误请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wcf webHttp端点并且今天注意到当调用带有长URL的httpGet~364个字符(http:// etc count)时,IIS会抛出400个错误的请求错误。在代码中抛出一个断点永远不会到达。如果我删除了一些参数并且网址为354,那么Web服务将按预期运行。

I have a wcf webHttp endpoint and noticed today that when called httpGet with a long url ~364 total characters (http:// etc counted) IIS throws a 400 bad request error. Throwing a breakpoint in the code never gets reached. If I remove some parameters and have a url that is 354 the web service runs as expected.

我不确定问题在哪里,因为网址可能像2k一样。我没有发布任何数据,所以我认为我没有达到4mb的限制,如来自这里

I'm not sure where the issue is since urls can be like 2k. I'm not posting any data so I don't think I'm hitting a 4mb limit like from here

给出了什么?

这里有一些wcf xml的东西。

Here's some wcf xml stuff.

    <behaviors>
        <endpointBehaviors>
            <behavior name="REST">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>

<endpoint address="" behaviorConfiguration="REST" binding="customBinding" bindingConfiguration="jsonpBinding" contract="Interface"/>


<bindings>
        <customBinding>
            <binding name="jsonpBinding">
                <jsonpMessageEncoding/>
                <httpTransport manualAddressing="true"/>
            </binding>
        </customBinding>
    </bindings>
    <extensions>
        <bindingElementExtensions>
            <add name="jsonpMessageEncoding" type="Microsoft.Ajax.Samples.JsonpBindingExtension, service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
        </bindingElementExtensions>
    </extensions>

我刚刚删除了回调函数名称,这显着减少了网址的大小,但它仍然扔了400错误。这让我觉得可以作为字符串参数发送的文本有一个WCF大小限制。

I just removed the callback function name which significantly reduced the size of the url and it still threw a 400 error. This makes me think that there is a WCF size limit on the text that can be sent in as a string parameter.

这里;一些合同的东西

    [OperationContract]
[WebGet(UriTemplate = @"{userName}/layer({layerName})returnAttributes({attributeList})where({attributeName})({op})({attributeValue})", ResponseFormat = WebMessageFormat.Json)]
[JSONPBehavior(callback = "callback")]
DojoGrouping GetAttributes(string userName, string layerName, string attributeList, string attributeName, string attributeValue);

问题在于可以用逗号分隔列表的attributeList。

the issue is with attributeList which can be comma separated list.

所以使用网址调用,如

http://../演示/层(OfficialsLookup)returnAttributes(USHOUSE,US_Photo,US_Web,US_Name,SENDIST,SEN_Name,SEN_Email,SEN_Party,SEN_Photo,REPDIST,REP_Name,REP_Email,REP_Party,REP_Web,REP_Photo)utmX(430)utmY(4502)

它破灭了。但是如果我缩短返回属性文本,那么它就能正常运行。

it busts. But if i shorten the return attribute text then it functions properly.

I've added I added the following entry into the registry: 
Key Name: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters 
Class Name: <NO CLASS> 
Last Write Time: 1/25/2011 - 3:34 PM 
Value 0 
Name: UrlSegmentMaxLength 
Type: REG_DWORD 
Data: 0x200 

我在添加机器后重新启动机器,但仍然收到相同的错误。这是修改WCF和IIS正在使用的HTTP.sys设置的正确位置吗?有没有办法测试WCF是否受此注册表值的影响?

I rebooted the machine after adding it and am still receiving the same error. Is this the correct spot to be modifying the HTTP.sys settings that WCF and IIS are using? Is there a way to test that WCF is being affected by this registry value?

这是一个相关的帖子,没有回答,但说​​httpsys的东西没有修复64我们正在使用的位服务器。

Here is a related post with no answer but saying that the httpsys stuff did not fix a 64 bit server which is what we are using.

相关文章

推荐答案

要解决我们的问题,我们必须使用.NET 4.0框架。我们将Web服务移动到.net 4.0应用程序池下运行,并将目标框架更改为4.0。这导致网站吐出url太长错误而不是只是一个错误的请求。在

To fix our issue we had to use the .NET 4.0 framework. We moved the web service to run under a .net 4.0 app pool and changed the target framework to 4.0. This caused the site to spit out url is too long error instead of just a bad request. After adding a web config entry in

<system.web>

已添加

<httpRuntime maxUrlLength="500" />

对于最大网址长度,服务已按预期启动并运行。

for max url length, the service is up and running as expected.

这篇关于WCF URL长度导致IIS 400错误请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆