其中WCF服务可以处理通过在WCF结合MaxReceivedMessageSize属性控制所述请求的最大大小。 默认值是65536,超过此值可以获得400响应代码。
在网站托管服务的web.config文件,在部分添加以下节点。
<system.serviceModel>
<services>
<!-- The name of the service -->
<service name="NorthwindService">
<!-- you can leave the address blank or specify your end point URI -->
<endpoint address ="YourServiceEndpoint"
binding="webHttpBinding" bindingConfiguration="higherMessageSize"
contract ="System.Data.Services.IRequestHandler">
</endpoint>
</service>
</services>
<bindings>
<webHttpBinding>
<!-- configure the maxReceivedMessageSize value to suit the max size of
the request (in bytes) you want the service to recieve-->
<binding name="higherMessageSize" maxReceivedMessageSize ="MaxMessageSize"/>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
如果托管在IIS中,ASP.Net请求大小限制也可能导致大的请求被拒绝,你将需要设置HttpRuntimeSection.MaxRequestLength属性。
<system.web>
<httpRuntime MaxRequestLength="ValueInKiloBytes" />
</system.web>
确定WCF是否抛出了一个异常,而这些异常是在HTTP级别上未呈现给您的。您可以configure WCF tracing on the server-side从WCF层记录必要的信息。一旦跟踪设置并重现失败,请检查日志是否包含这些异常消息中的一个或两个。
System.ServiceModel.ProtocolException
"The maximum message size quota for incoming messages (65536) has been exceeded.
To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."
System.Web.HttpException
"Maximum request length exceeded."
如果您看到日志包含此消息,那么可以肯定的是,失败是因为消息的大小和应用此相应的修正。
PD:请记住,您的表单必须使用"POST"
方法。
你在哪里更改MaxReceivedMessageSize? – cmsjr 2009-01-12 01:03:24