传递警报List时WCF抛出错误。 “远程服务器返回了意外响应:(400)错误请求。” [英] WCF throwing error when alarge List is passed To it. "The remote server returned an unexpected response: (400) Bad Request."

查看:59
本文介绍了传递警报List时WCF抛出错误。 “远程服务器返回了意外响应:(400)错误请求。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含9个字段的列表。当我通过一个较小的列表(比如说50行)时,应用程序运行正常。如果我传递一个更大的列表,我的服务就会抛出异常远程服务器返回了一个意外的响应:(400)Bad Request。例外。请帮我解决这个问题。



我的网页配置如下

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

<!--
  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" />

  </add></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="/" />
      </add></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" />
          </transport></security>
        </readerquotas></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" />
          </transport></security>
        </readerquotas></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" />
          </transport></security>
        </readerquotas></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" />
    </endpoint></endpoint></endpoint></client>
  </system.servicemodel>
</configuration>





和我的wcf配置如下



and my wcf config is as below

<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

<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>
      </endpoint></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>
      </endpoint></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>
      </endpoint></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" />
        </transport></security>
      </readerquotas></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" />
          </transport></security>
        </readerquotas></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" />
          </transport></security>
        </readerquotas></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


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

推荐答案

Dude if you are using entity framework disable lazy loading then it should work.
Dude if you are using entity framework disable lazy loading then it should work.


这篇关于传递警报List时WCF抛出错误。 “远程服务器返回了意外响应:(400)错误请求。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆