0

I have a wpf application which is sending a DataSet with almost 25 DataTable. I am not able to fix The remote server returned an unexpected response: (400) Bad Request with synchronous and asynchronous both. Below is the 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>

and this is the Service's 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>

P.S.: I tested it with passing blank DataSet, Its working. But DataSet with DataTable its not working.

4

1 回答 1

0

我已经包含了整个服务模型供您参考,请将我设置为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>
于 2013-04-18T14:16:43.267 回答