The remote server returned an error: (413) Request Entity Too Large in WCF

The remote server returned an error: (413) Request Entity Too Large in WCF

WCF 服务正在返回

The remote server returned an error: (413) Request Entity Too Larg

但数据大小只有 80KB,我配置的最大大小为 2GB。我尝试了堆栈溢出,但我仍然面临同样的问题。

配置:

<service name="HP.VFS.ShoppingcartService.ShoppingCart">
    <endpoint name="SOAPEndPoint" contract="HP.VFS.ShoppingcartService.IShoppingCart" binding="basicHttpBinding" address="soap" />
    <endpoint name="RESTEndPoint" contract="HP.VFS.ShoppingcartService.IShoppingCart" binding="webHttpBinding" address="api" behaviorConfiguration="restbehavior" /> <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>

<basicHttpBinding>
    <binding name="basicHttpBinding" closeTimeout="10:00:00" receiveTimeout="10:00:00" sendTimeout="10:00:00">
         <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
    <binding name="soap" closeTimeout="10:00:00" receiveTimeout="10:00:00" sendTimeout="10:00:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
</basicHttpBinding>

服务器端接口

[OperationContract(Name = "wstCreateOrder")]
[FaultContract(typeof(ApplicationFault))]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,UriTemplate = "/wstCreateOrder/OrderInfo")]
string CreateOrder(string OrderInfo);

在客户端

Service.CreateOrder(80+ KB string);

我正在访问 WCF 服务,以便在 MVC4 .Net 应用程序中通过 SOAP 协议传输数据。参数均为字符串类型。如果文本大小超过 60 KB,则在调用该方法时会抛出类似 "The remote server returned an error: (413) Request Entity Too Larg" 的错误。但是在基于 Whosebug 指南的服务器配置中,我为配置中收到的最大消息添加了最大大小,但仍然面临同样的问题,请帮助我。

谢谢大家。最后我得到了解决方案。解决方案只是将 maxDepth“2000000”的大小增加到“2147483647”问题已解决。