如何使用EF 6设置WCF数据服务(odata)的配置文件 [英] How do I setup config files for WCF Data Service (odata) with EF 6

查看:81
本文介绍了如何使用EF 6设置WCF数据服务(odata)的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已启动并运行数据服务,但出现此错误:

I have a data service up and running, but I'm getting this error:

远程服务器返回错误:(413)请求实体太大.

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

我已经尝试了很多方法来解决此问题,但是没有运气. 我已将网站上的uploadReadAheadSize和IIS中的数据服务设置为最大设置. 我还尝试了一些不同的配置文件设置.

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. I have also tried a number of different setups for the config files.

这是客户端的当前app.config:

Here is the current app.config for the client:

  <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>

我尝试了WCFWebBinding和WCFHttpBinding这两个绑定.

I have tried both bindings, WCFWebBinding and WCFHttpBinding.

这是Web服务web.config.

Here is the web service 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.

推荐答案

我找到了解决此问题的方法. web.config必须添加一个名为该服务的服务,并且合同必须设置为"System.Data.Services.IRequestHandler"

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"

<system.serviceModel>
<services>
  <service name="PSIDataService.PSIWcfDataService">
    <endpoint bindingConfiguration="msgSize" 
              address="" 
              binding="webHttpBinding" 
              contract="System.Data.Services.IRequestHandler"/>
  </service>
</services>

我的系统同时抱怨服务名称和合同(属性是无效的警告).我的服务的名称空间是PSIDataService,类名称是PSIWcfDataService,因此我忽略了投诉.合同名称具有相同的警告.我知道该接口存在,所以我也忽略了该警告.

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. The contract name had the same warning. I knew the interface existed, so I ignored that warning, too.

还需要一个webHttpBinding.

A webHttpBinding is also required.

  <bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_ILogging" />
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="msgSize" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
  </webHttpBinding>
</bindings>

我从Malvin Ly( malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize )谢谢马尔文!我不喜欢警告,但这解决了我的问题.

I got the idea for this fix from Malvin Ly (malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize) So thanks Malvin! I don't like the warnings, but this solved my problem.

这篇关于如何使用EF 6设置WCF数据服务(odata)的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆