0

I have a list which has 9 fields. When i pass A smaller list (say 50 rows) the application is working fine. If i pass a larger list my service is throwing the exception "The remote server returned an unexpected response: (400) Bad Request." exception. please help me solving this issue.

My Web config is as below

 <?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />

  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Windows">
            <!--<forms loginUrl="~/Account/Login.aspx" timeout="2880" />-->
    </authentication>
    <identity impersonate="false" />
    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

    <httpRuntime maxRequestLength="2147483647" executionTimeout="3600"/>

  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors >
        <behavior name="Behavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" closeTimeout="00:20:00"
        openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" 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">
            <transport clientCredentialType="Windows" proxyCredentialType="Windows"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IErrorService" closeTimeout="00:20:00"
        openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" 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">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>            
        <binding name="BasicHttpBinding_ISecurityUserService" closeTimeout="00:20:00"
        openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" 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">
            <transport clientCredentialType="Windows" proxyCredentialType="Windows"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:6789/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
        name="BasicHttpBinding_IService1" />
      <endpoint address="http://localhost:6789/ErrorService.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IErrorService" contract="ErrorServiceReference.IErrorService"
        name="BasicHttpBinding_IErrorService" />
      <endpoint address="http://localhost:6789/SecurityUserService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISecurityUserService"
        contract="SecurityUserServiceReference.ISecurityUserService"
        name="BasicHttpBinding_ISecurityUserService" />          
    </client>
  </system.serviceModel>
</configuration>

and my wcf config is as below

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

        <add name="DEFAULT"  connectionString="server=DEV1;Port=52;database=UTIL;User=ara;password=me;Charset=iso_1;Connect Timeout=100" />

      </connectionStrings>
      <appSettings>
        <add key="DEFAULT_SERVER" value="UAT"/>
        <add key="DEFAULT_DATABASE" value="UTIL"/>
        <add key="DEFAULT_PORT" value="480"/>
        <add key="DEFAULT_USER" value="fator"/>
        <add key ="DEFAULT_PASSWORD" value="U212ajUyODY="/>
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />

          <httpRuntime maxRequestLength="2147483647" executionTimeout="3600"/>

      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="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="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>

        <services>

        </services>

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>

    </configuration>

I modified my service web config with endpoint and binding as below. but still I am getting the same error

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

    <add name="DEFAULT"  connectionString="server=DEV;Port=52;database=UTIL;User=ar;password=me3;Charset=iso_1;Connect Timeout=100" />

  </connectionStrings>
  <appSettings>
    <add key="DEFAULT_SERVER" value="UA"/>
    <add key="DEFAULT_DATABASE" value="UTIL"/>
    <add key="DEFAULT_PORT" value="45"/>
    <add key="DEFAULT_USER" value="fr"/>
    <add key ="DEFAULT_PASSWORD" value="Y="/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />

      <httpRuntime maxRequestLength="2147483647" executionTimeout="3600"/>

  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="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="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service name="Service.Service1" behaviorConfiguration="Behavior">
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_IService1"
                  contract="Service.IService1"
                  name="BasicHttpBinding_IService1" />
        <endpoint address="mex" 
                  binding="mexHttpBinding"
                  contract="IMetaDataExchange"></endpoint>
        <host>
          <timeouts openTimeout="00:30:00" />
        </host>
      </service>
      <service name="Service.ErrorService" behaviorConfiguration="Behavior">
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_IErrorService"
                  contract="Service.IErrorService"
                  name="BasicHttpBinding_IErrorService" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetaDataExchange"></endpoint>
        <host>
          <timeouts openTimeout="00:30:00" />
        </host>
      </service>
      <service name="Service.SecurityUserService" behaviorConfiguration="Behavior">
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_ISecurityUserService"
                  contract="Service.ISecurityUserService"
                  name="BasicHttpBinding_IErrorService" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetaDataExchange"></endpoint>
        <host>
          <timeouts openTimeout="00:30:00" />
        </host>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
      <binding name="BasicHttpBinding_IService1" closeTimeout="00:20:00"
        openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="2147483647" 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">
          <transport clientCredentialType="Windows" proxyCredentialType="Windows"
            realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
        <binding name="BasicHttpBinding_IErrorService" closeTimeout="00:20:00"
        openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" 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">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_ISecurityUserService" closeTimeout="00:20:00"
        openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" 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">
            <transport clientCredentialType="Windows" proxyCredentialType="Windows"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

I guess The endpoint and the binding i defined explicitly are not getting used by the service. please correct me if i have configured The service wrong

4

1 回答 1

1

试试下面的标签

您的应用程序中的问题是您使用不同的合同名称进行服务。在 Web.Config 中,您将合同名称用作 Service1 的“ServiceReference1.IService1”,而在服务 Web 配置中,您将合同名称用作“Service.IService1”。也许它会解决你的问题。

<system.serviceModel>
    <diagnostics performanceCounters ="All"/>  
    <services>
      <service behaviorConfiguration ="Default" name ="Service.IService1">
        <endpoint address="" behaviorConfiguration="Web" binding ="basicHttpBinding" contract ="ServiceReference1.IService1"></endpoint>
        <host>
          <baseAddresses>                
          </baseAddresses>
        </host>
      </service>      
    </services>
    <behaviors>      
      <serviceBehaviors>
        <behavior name ="Default">

          <serviceThrottling maxConcurrentCalls ="100" maxConcurrentSessions ="100"/>
          <!-- 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>
      <endpointBehaviors>
        <behavior name ="Web"></behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment  multipleSiteBindingsEnabled="true" />

  </system.serviceModel>
于 2013-04-18T14:24:43.540 回答