WCF Web服务。不允许发送超过8kb的数据

时间:2010-03-15 13:37:32

标签: wcf web-services

我开发了一个WCF WebService。在客户端,他们无法发送超过8kb的文件字节[]。如何增加客户端和上传的字节数以及超时时间。

<system.serviceModel>
    <!-- Test File Size  -->
    <binding maxReceivedMessageSize="2147483647">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
        maxNameTableCharCount="2147483647" >
    </binding>

        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <services>
            <service name="WcfSmartConnect.Service1" behaviorConfiguration="WcfSmartConnect.Service1Behavior">
                <!-- Service Endpoints -->
                <endpoint address="" binding="wsHttpBinding" contract="WcfSmartConnect.IService1">
                    <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="WcfSmartConnect.Service1Behavior">
                    <!-- 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 httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

2 个答案:

答案 0 :(得分:1)

将此添加到端点标记:

bindingconfiguration="wsHttp"

在system.serviceModel标记

中添加这个完整的绑定配置标记
<binding name="wsHttp" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
        maxNameTableCharCount="2147483647" >
</binding>

答案 1 :(得分:1)

也许不是直接答案,但对于大文件,您确实应该关注MTOMstreaming