我正在尝试将 BMP 文件作为 WCF 服务中的参数传递。当 BMP 文件的大小为 350kb 时出现错误。当我传递一个 10-20 kb 的小文件时,它运行良好。
The remote server returned an unexpected response: (413) Request Entity Too Large.
[OperationContract]
byte[] ConvertData(Bitmap bmp);
我试图通过以下链接更改 IIS 设置来解决问题:http: //blogs.msdn.com/b/jiruss/archive/2007/04/13/http-413-request-entity-too-large-can -t-upload-large-files-using-iis6.aspx但没有运气
我的服务器 web.config 是
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240000"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ReDrawImgService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="ReDrawImgService.IService1"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
我的客户端 Web.Config 是
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240000"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ReDrawImgService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="ReDrawImgService.IService1"/>
</service>
</services>
<client>
<endpoint address="http://localhost:8012/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceClient.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>