[英]How do I setup config files for WCF Data Service (odata) with EF 6
I have a data service up and running, but I'm getting this error:我有一个数据服务正在运行,但出现此错误:
The remote server returned an error: (413) Request Entity Too Large.
远程服务器返回错误:(413) 请求实体太大。
I have tried a number of things to fix this with no luck.我已经尝试了很多方法来解决这个问题,但没有运气。 I have set the uploadReadAheadSize on the Web Site and the Data Service in IIS to the max setting.
我已将网站上的 uploadReadAheadSize 和 IIS 中的数据服务设置为最大设置。 I have also tried a number of different setups for the config files.
我还为配置文件尝试了许多不同的设置。
Here is the current app.config for the client:这是客户端的当前 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>
I have tried both bindings, WCFWebBinding and WCFHttpBinding.我尝试了两种绑定,WCFWebBinding 和 WCFHttpBinding。
Here is the web service web.config.这是 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>
Again, I have tried both bindings.同样,我已经尝试了两种绑定。 I don't know what else can be done.
我不知道还能做什么。 Any help would be great.
任何帮助都会很棒。
I have found a solution to this problem.我找到了解决这个问题的方法。 The web.config must have a service added that names the service and has a contract set to "System.Data.Services.IRequestHandler"
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>
My system complained about both the name of the service and the contract (attribute is invalid warnings).我的系统同时抱怨服务名称和合同(属性无效警告)。 The namespace of my service is PSIDataService and the class name is PSIWcfDataService, so I ignored the complaint.
我的服务的命名空间是 PSIDataService,类名是 PSIWcfDataService,所以我忽略了投诉。 The contract name had the same warning.
合约名称也有同样的警告。 I knew the interface existed, so I ignored that warning, too.
我知道接口存在,所以我也忽略了那个警告。
A webHttpBinding is also required.还需要一个 webHttpBinding。
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
</basicHttpBinding>
<webHttpBinding>
<binding name="msgSize" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</webHttpBinding>
</bindings>
I got the idea for this fix from Malvin Ly ( malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize ) So thanks Malvin!我从 Malvin Ly ( malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize ) 那里得到了这个修复的想法,所以谢谢 Malvin! I don't like the warnings, but this solved my problem.
我不喜欢这些警告,但这解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.