当前位置:编程学习 > C#/ASP.NET >>

关于WCF传输的送分问题。

请各位大侠帮个忙。WCF服务端接收数据的量很大,网上找了很多方法也解决不了,请各位帮忙看一下。
项目是用VS2010创建的,服务端web.config文件如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpRuntime maxRequestLength="2147483647"/>
    </system.web>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
                <behavior name="QuestionServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <dataContractSerializer maxItemsInObjectGraph="2147483647" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service name="SchoolDataService.IQuestionService" behaviorConfiguration="QuestionServiceBehavior">
                <endpoint address="http://192.168.0.8:8002/QuestionService.svc" binding="wsHttpBinding" contract="SchoolDataService.IQuestionService">
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <bindings>
            <wsHttpBinding>
                <binding closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                  messageEncoding="Text" textEncoding="utf-8"
                  useDefaultWebProxy="true">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None"> </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
</configuration>

服务器上还有其他服务,VS2010没有在web.config文件中加入,只有QuestionService服务需要大量数据接收。

下面是客户端的app.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IPaperService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
                <binding name="BasicHttpBinding_IQuestionService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://192.168.0.8:8002/PaperService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPaperService"
                contract="Server_PaperService.IPaperService" name="BasicHttpBinding_IPaperService" />
            <endpoint address="http://localhost:3115/QuestionService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IQuestionService"
                contract="Server_QuestionService.IQuestionService" name="BasicHttpBinding_IQuestionService" behaviorConfiguration="QuestionServiceBehavior" />
        </client>
        <behaviors>
            <endpointBehaviors>
                <behavior name="QuestionServiceBehavior">
                    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>


错误信息是:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:question. The InnerException message was 'There was an error deserializing the object of type SchoolData.Model.Question. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 6, position 30576.'.  Please see InnerException for more details. --------------------编程问答-------------------- 没有人帮忙吗? --------------------编程问答-------------------- 提示你的信息是The maximum string content length quota (8192) has been exceeded while reading XML data 执行的是8192 不是你定义的数值 --------------------编程问答-------------------- 在你客户端配置中 <basicHttpBinding>
下的
 BasicHttpBinding_IPaperService
里的
最大接收大小及最大缓冲大小设置的是默认的。把它修改了就成 --------------------编程问答-------------------- 顶顶
补充:.NET技术 ,  Web Services
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,