我创建了WCF服务,用于将1MB文件数据上传到Windows Server。此Web服务可以很好地处理小文件(950 KB)数据,但是文件大小较大时会出现问题。
我尝试了几种方法在WCF web.config中修复它,但仍然停留在上述错误中。我需要帮助来设置WCF配置以解决我的问题。
这是我的web.config,如下所示:
<system.serviceModel>
<services>
<service name="WCFService.UploadService">
<endpoint address="REST" behaviorConfiguration="WCFServiceBehavior" binding="webHttpBinding" bindingConfiguration="WCFServiceBinding" contract="WCFService.IUploadService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="WCFServiceBinding" maxReceivedMessageSize="1073741824" maxBufferSize="20971520" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="WCFServiceBehavior">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
</system.serviceModel>
请在WCF web.config上正确无误
答案 0 :(得分:0)
请参考以下配置,它同时支持Http和Https。您可以根据需要剪切它。此外,我使用ProtocolMapping功能来简化配置。
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" name="httpbinding">
<security mode="None">
</security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147473647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
</binding>
<binding name="httpsbinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147473647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<!--http and https are all supported.-->
<add binding="webHttpBinding" scheme="http" bindingConfiguration="httpbinding"/>
<add binding="webHttpBinding" scheme="https" bindingConfiguration="httpsbinding"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
有关如何简化配置,
https://docs.microsoft.com/en-us/dotnet/framework/wcf/simplified-configuration
随时让我知道问题是否仍然存在。