C# 将大型数据集发送到WCF服务会导致协议异常

C# 将大型数据集发送到WCF服务会导致协议异常,c#,wcf,dataset,C#,Wcf,Dataset,我有一个wpf应用程序,它正在发送一个数据集,其中几乎有25个数据表。我无法修复远程服务器返回了一个意外的响应:(400)错误的请求,同时使用同步和异步。下面是app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding&

我有一个wpf应用程序,它正在发送一个
数据集
,其中几乎有25个
数据表
。我无法修复
远程服务器返回了一个意外的响应:(400)错误的请求
,同时使用同步和异步。下面是app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_ICommunication" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="01:00:00" sendTimeout="01:00: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://localhost:49486/Communication.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICommunication"
                contract="CommunicationReference.ICommunication" name="BasicHttpBinding_ICommunication" />
        </client>
    </system.serviceModel>
</configuration>

这是服务的web.config:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647" executionTimeout="10000"/>
  </system.web>
  <connectionStrings>
    <add name="conName" connectionString="Data Source=*******;Initial Catalog=****; User ID=**; Password=*****"/>  

  </connectionStrings>
  <system.serviceModel>   

    <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"/>
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="1000" maxConcurrentInstances="1600" />
        </behavior>
      </serviceBehaviors>
    </behaviors>    
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>  
</configuration>


附言:我用传递空白的
数据集
测试了它,它工作正常。但是
DataSet
DataTable
不起作用。

我已经包含了整个服务模型供您参考,请将我设置为LargeDataService的合同设置到您适当的界面

<system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        <bindings>
            <basicHttpBinding>
                <binding name="LargeDataBinding" maxReceivedMessageSize="4194304">
                    <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
                </binding>
            </basicHttpBinding>
        </bindings>
        <services>
            <service behaviorConfiguration="webBehavior" name="serviceEndpoints">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeDataBinding" behaviorConfiguration="customBehavior" contract="LargeDataService"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="webBehavior">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <dataContractSerializer maxItemsInObjectGraph="2147483646" />
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors>
                <behavior name="customBehavior">
                    <webHttp automaticFormatSelectionEnabled="false" helpEnabled="true"/>
                    <dataContractSerializer maxItemsInObjectGraph="2147483646" />
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>


您的WCF服务上定义的ReaderQuota设置是否相同?同时启用跟踪()并检查跟踪文件,以查看导致400个错误请求的原因异常您可以发布服务器代码,返回数据表吗?我没有返回,我正在将其传递给web服务您是否尝试使用空数据表创建数据集?@evgeny,是的,它正在使用空数据集为WCF服务,请记住在我必须添加标记的Endpoint的contract属性中设置服务接口?注释掉旧的system.serviceModel块并将此块移到它的位置让我们