Mar*_*afe 3 wcf wcf-data-services odata
我有一个数据服务启动并运行,但我收到此错误:
远程服务器返回错误:(413)请求实体太大.
我已经尝试过许多方法来解决这个问题而没有运气.我已将网站上的uploadReadAheadSize和IIS中的数据服务设置为最大设置.我还为配置文件尝试了许多不同的设置.
这是客户端的当前app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
<binding name="WCFHttpBinding"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647"
maxDepth="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/PSIDataService/PSIWcfDataService.svc"
binding="webHttpBinding" bindingConfiguration="WCFWebBinding"
name="WCFWebBinding" contract="*"/>
</client>
Run Code Online (Sandbox Code Playgroud)
我尝试了两种绑定,WCFWebBinding和WCFHttpBinding.
这是web服务web.config.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="WCFHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/PSIDataService/PSIWcfDataService.svc"
binding="basicHttpBinding"
bindingConfiguration="WCFHttpBinding"
name="WCFHttpBinding"
contract="*"/>
</client>
Run Code Online (Sandbox Code Playgroud)
再次,我尝试了两种绑定.我不知道还能做些什么.任何帮助都会很棒.
我找到了解决这个问题的方法.web.config必须添加一个服务命名服务,并将合同设置为"System.Data.Services.IRequestHandler"
<system.serviceModel>
<services>
<service name="PSIDataService.PSIWcfDataService">
<endpoint bindingConfiguration="msgSize"
address=""
binding="webHttpBinding"
contract="System.Data.Services.IRequestHandler"/>
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
我的系统抱怨服务名称和合同(属性是无效警告).我的服务的命名空间是PSIDataService,类名是PSIWcfDataService,所以我忽略了投诉.合同名称具有相同的警告.我知道界面存在,所以我也忽略了这个警告.
还需要webHttpBinding.
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
</basicHttpBinding>
<webHttpBinding>
<binding name="msgSize" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</webHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
我从Malvin Ly得到了这个修复的想法(malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize)所以感谢Malvin!我不喜欢警告,但这解决了我的问题.