实体框架数据服务作为 Windows 服务如何更改 maxReceivedMessageSize
Entity Famework Data Service as a Windows Service how to change maxReceivedMessageSize
我正在尝试为我的 DataService 增加 maxReceivedMessageSize
。我试过这些地方的解决方案:
- https://malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize/
- How do I setup config files for WCF Data Service (odata) with EF 6
还有其他一些我不记得但无法正常工作的地方。 DataService 不是 运行 Web 应用程序,而是 Windows 服务。 app.config
目前看起来像这样:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" bindingConfiguration="Test"/>
</protocolMapping>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpsBinding>
<binding name="Test" maxBufferSize="10485760" maxReceivedMessageSize="10485760">
<readerQuotas maxDepth="10485760" maxStringContentLength="10485760"
maxArrayLength="10485760" maxBytesPerRead="10485760" maxNameTableCharCount="10485760" />
</binding>
</basicHttpsBinding>
</bindings>
</system.serviceModel>
编辑
我已经更新了 app.config 内容...仍然不知道应该如何完成。
编辑
按照建议我也设置了 readerQuotas
但没有成功
一段时间后我们找到了解决方案...
最初我们使用 DataServiceHost
class 来托管不支持这些选项的服务。在使用 WebServiceHost
托管服务后它起作用了:
WebServiceHost webServiceHost = new WebServiceHost(typeof(EfoDataService), new Uri[] { });
//Https binding
WebHttpBinding httpsbinding = new WebHttpBinding()
{
Security = { Mode = WebHttpSecurityMode.Transport },
MaxReceivedMessageSize = 2097152,
MaxBufferSize = 2097152,
MaxBufferPoolSize = 2097152,
TransferMode = TransferMode.Streamed
};
//adding https endPoint
webServiceHost.AddServiceEndpoint(typeof(IRequestHandler), httpsbinding, secureBaseAddress);
有点奇怪,因为 DataServiceHost
确实派生自 WebServiceHost
。
我正在尝试为我的 DataService 增加 maxReceivedMessageSize
。我试过这些地方的解决方案:
- https://malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize/
- How do I setup config files for WCF Data Service (odata) with EF 6
还有其他一些我不记得但无法正常工作的地方。 DataService 不是 运行 Web 应用程序,而是 Windows 服务。 app.config
目前看起来像这样:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" bindingConfiguration="Test"/>
</protocolMapping>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpsBinding>
<binding name="Test" maxBufferSize="10485760" maxReceivedMessageSize="10485760">
<readerQuotas maxDepth="10485760" maxStringContentLength="10485760"
maxArrayLength="10485760" maxBytesPerRead="10485760" maxNameTableCharCount="10485760" />
</binding>
</basicHttpsBinding>
</bindings>
</system.serviceModel>
编辑
我已经更新了 app.config 内容...仍然不知道应该如何完成。
编辑
按照建议我也设置了 readerQuotas
但没有成功
一段时间后我们找到了解决方案...
最初我们使用 DataServiceHost
class 来托管不支持这些选项的服务。在使用 WebServiceHost
托管服务后它起作用了:
WebServiceHost webServiceHost = new WebServiceHost(typeof(EfoDataService), new Uri[] { });
//Https binding
WebHttpBinding httpsbinding = new WebHttpBinding()
{
Security = { Mode = WebHttpSecurityMode.Transport },
MaxReceivedMessageSize = 2097152,
MaxBufferSize = 2097152,
MaxBufferPoolSize = 2097152,
TransferMode = TransferMode.Streamed
};
//adding https endPoint
webServiceHost.AddServiceEndpoint(typeof(IRequestHandler), httpsbinding, secureBaseAddress);
有点奇怪,因为 DataServiceHost
确实派生自 WebServiceHost
。