[英]Windows Service (413) Request Entity Too Large
Please do not delete this as a duplicate I have a windows service that I am passing an array of objects to. 请不要将其作为重复项删除。我有一个Windows服务,正在向其中传递对象数组。 When the array contains less than 150 objects it works successfully.
当数组包含少于150个对象时,它将成功工作。 When I pass more than 150 objects I get the (413) Request Entity Too Large Error.
当我传递超过150个对象时,我收到(413)请求实体太大错误。
I have tried the feedback from other articles regarding readerQuotas node values and maxReceivedMessageSize, but I am still receiving the error and I am stuck as to what I am still doing wrong. 我已经尝试了其他文章中有关readerQuotas节点值和maxReceivedMessageSize的反馈,但是我仍然收到该错误,并且我仍然在做错误的事情。 Here is the app.config of the windows service:
这是Windows服务的app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingNoSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None"/>
<message establishSecurityContext="false" negotiateServiceCredential="false"/>
</security>
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="SE.Responder.Integration.AmiOutboundService.AmiObService" behaviorConfiguration="Service1Behavior">
<endpoint address="wsHttp" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoSecurity" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="basicHttp" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" name="basicHttp" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
And here is the app.config of the executable that passes the data to the windows service: 这是将数据传递到Windows服务的可执行文件的app.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAmiObService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/AmiOBService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAmiObService" contract="AmiObService.IAmiObService" name="WSHttpBinding_IAmiObService" />
</client>
After reviewing the source code for the application that was having this issue, I found that the wcf service was being hosted in the C# code. 查看存在此问题的应用程序的源代码后,我发现wcf服务托管在C#代码中。 I then applied the fix in code as described in the following stack overflow issue, MaxReceivedMessageSize in WCF Hosted Service in console application , specifically the following lines, var wsHttpBinding = new WSHttpBinding();
然后,我按照下面的堆栈溢出问题( 在控制台应用程序中的WCF托管服务中的MaxReceivedMessageSize中所述)在代码中应用了此修复程序 ,特别是以下几行:var wsHttpBinding = new WSHttpBinding(); wsHttpBinding.MaxReceivedMessageSize = int.MaxValue;
wsHttpBinding.MaxReceivedMessageSize = int.MaxValue; Service.AddServiceEndpoint(typeof(TInterfaceContract), wsHttpBinding, EndpointAddress);
Service.AddServiceEndpoint(typeof(TInterfaceContract),wsHttpBinding,EndpointAddress);
which corrected the issue. 纠正了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.