1

我正在尝试将 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>
4

1 回答 1

1

在您的 readerQuotas 上,尝试将 maxStringContentLength 也设置为 2147483647,并确保在两端都设置了此配置。

所以服务器和客户端都需要有这些值。如果允许客户端发送一个大文件,如果服务器无论如何都会拒绝它,那也无济于事。

maxArrayLengthwcf 服务器应用程序的价值是什么

于 2013-02-26T08:28:18.943 回答