且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

大WCF Web服务请求与(400)HTTP错误的请求失败

更新时间:2022-03-24 22:32:03

尝试设置maxReceivedMessageSize在服务器上也是如此,例如,为4MB:

Try setting maxReceivedMessageSize on the server too, e.g. to 4MB:

    <binding name="MyService.MyServiceBinding" 
           maxReceivedMessageSize="4194304">

主要原因默认(65535我相信)是如此之低,是减少拒绝服务(DoS)攻击的风险。需要设置它比服务器上的最大请求大小,并在客户端上的最大响应大小更大。如果你是在Intranet环境,DoS攻击的风险的攻击,可能是低的,所以它可能是安全使用的值比预期需要的要高得多。

The main reason the default (65535 I believe) is so low is to reduce the risk of Denial of Service (DoS) attacks. You need to set it bigger than the maximum request size on the server, and the maximum response size on the client. If you're in an Intranet environment, the risk of DoS attacks is probably low, so it's probably safe to use a value much higher than you expect to need.

顺便说一对连接到WCF服务,故障排除提示:

By the way a couple of tips for troubleshooting problems connecting to WCF services:

使用一个HTTP调试工具,如提琴手在客户端上,以检查HTTP流量。

Use an HTTP debugging tool such as Fiddler on the client to inspect the HTTP traffic.