Getting "The remote server returned an unexpected response: (400) Bad Request"

Getting "The remote server returned an unexpected response: (400) Bad Request"

Old forum URL: forums.lhotka.net/forums/t/7422.aspx


mkadlec posted on Friday, August 07, 2009

Hi,

  I am running a WPF app with a remote server setup but get the error listed.

This is definitely a request size issue since I tried reducing the data size being sent and the call worked fine.  From my configuration it looks like I have 2 Gigs set up, but it behaves like only the default limit (something like 65000 bytes) is being used.  I am thinking there is something wrong with my configuration.

Any help would be appreciated!

Mark.

  I have a remote Server set up using WCF web.config:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="Csla.Server.Hosts.WcfPortal">
        <endpoint contract="Csla.Server.Hosts.IWcfPortal" binding="wsHttpBinding"/>
      </service>
    </services>
  </system.serviceModel>

And my app.config on the client is:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint name="WcfDataPortal" address="http://alcatraz.dev/AlcatrazHost/WcfPortal.svc" binding="wsHttpBinding" contract="Csla.Server.Hosts.IWcfPortal" bindingConfiguration="wsHttpBindingSettings" />
    </client>
  </system.serviceModel>



sergeyb replied on Friday, August 07, 2009

I am guessing you are missing this in web.confg

 

<system.web>

        <httpRuntime maxRequestLength="102400"/>

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: mkadlec [mailto:cslanet@lhotka.net]
Sent: Friday, August 07, 2009 5:42 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Getting "The remote server returned an unexpected response: (400) Bad Request"

 

Hi,

  I am running a WPF app with a remote server setup but get the error listed.

This is definitely a request size issue since I tried reducing the data size being sent and the call worked fine.  From my configuration it looks like I have 2 Gigs set up, but it behaves like only the default limit (something like 65000 bytes) is being used.  I am thinking there is something wrong with my configuration.

Any help would be appreciated!

Mark.

  I have a remote Server set up using WCF web.config:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="Csla.Server.Hosts.WcfPortal">
        <endpoint contract="Csla.Server.Hosts.IWcfPortal" binding="wsHttpBinding"/>
      </service>
    </services>
  </system.serviceModel>

And my app.config on the client is:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindin gs>
    <client>
      <endpoint name="WcfDataPortal" address="http://alcatraz.dev/AlcatrazHost/WcfPortal.svc" binding="wsHttpBinding" contract="Csla.Server.Hosts.IWcfPortal" bindingConfiguration="wsHttpBindingSettings" />
    </client>
  </system.serviceModel>





mkadlec replied on Friday, August 07, 2009

Thanks Sergey, but it looks like it is set high, I have it at:

    <system.web>
        <httpRuntime maxRequestLength="2097151" />

sergeyb replied on Friday, August 07, 2009

I just noticed that you do not specify binding configuration in your end point, so none of your limits are actually used.  You have to add bindingConfiguration node to your end point definition to point to your wsHttpBindingSettings configuration.,

 

 

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="Csla.Server.Hosts.WcfPortal">
        <endpoint contract="Csla.Server.Hosts.IWcfPortal" binding="wsHttpBinding"/>
      </service>
    </services>
  </system.serviceModel>

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: mkadlec [mailto:cslanet@lhotka.net]
Sent: Friday, August 07, 2009 5:59 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Getting "The remote server returned an unexpected response: (400) Bad Request"

 

Thanks Sergey, but it looks like it is set high, I have it at:

    <system.web>
        <httpRuntime maxRequestLength="2097151" />


Copyright (c) Marimer LLC