Large Wcf Web Service Request Failing with (400) Http Bad Request

Large WCF web service request failing with (400) HTTP Bad Request

Try setting maxReceivedMessageSize on the server too, e.g. to 4MB:

<binding name="MyService.MyServiceBinding" maxReceivedMessageSize="4194304">

The main reason the default (65535 I believe) is so low is to reduce the risk of Denial of Service (DoS) attacks. You need to set it bigger than the maximum request size on the server, and the maximum response size on the client. If you're in an Intranet environment, the risk of DoS attacks is probably low, so it's probably safe to use a value much higher than you expect to need.

By the way a couple of tips for troubleshooting problems connecting to WCF services:

  • Enable tracing on the server as described in this MSDN article.

  • Use an HTTP debugging tool such as Fiddler on the client to inspect the HTTP traffic.

HTTP 400 Bad Request on method GET request for WCFService

I needed to find the proper exception message. There are a couple different ways to do it, but the easiest in this case was to use fiddler (because the error was caused while using it). All I needed to do was paste the Uri I was using for the GET request and paste it in the browser. This gave me the exception and the trace details. I then used the exception message Login failed for user 'IIS APPPOOL\WCFService to search for an answer. The accepted answer on this question Login failed for user 'IIS APPPOOL\ASP.NET v4.0' is the solution (the login may or not slightly differ depending on exact error code and service that you are using)

Hope this helps someone else out there.

HTTP Bad Request (400) Error with a WCF Service with Multiple Endpoints

Can you try to inspect the request being sent to the server using tools like Fiddler. There must be something in the soap envelop that is causing the issue.

Also try to send small data initially to make sure your service is accessible and then try to larger data so that you can narrow down on where the problem is.

Have you implemented the async pattern or is your web service marked as Async=True.

Would be helpful if you can post your service as well.

HTTP Bad Request 400 WCF Soap Service in web cilent but not in chrome

You seem to be confusing SOAP and REST. REST is a method of using HTTP Verbs, status codes, and the URL path to make requests. In WCF, this is implemented using WebGet or WebInvoke. SOAP is 100% different than this. The parameters are passed to the service using a SOAP envelope. This is an XML based protocol. Essentially, a bunch of XML is sent in the request body representing a SOAP message. The response, likewise, is XML in the response body representing a SOAP message. Of course calling WebClient will not work. You're not sending a SOAP message. Instead, add a Service Reference to your WCF class. This will create a proxy class that can talk to your service. Right click on your Web References folder and choose Add Service Reference. MSDN has information on the process.

But in any case, getData/1 will never work with SOAP because it's not SOAP, it's REST. Think of it this way, you walked up to someone who only speaks Chinese and started speaking to him in English. When he hears you, he hears gibberish (Hey's expecting Chinese). When he responds (probably saying I have no idea what you're saying), you hear gibberish (You're expecting English). Until you either both speak English (REST) or Chinese (SOAP), there will be no communication happening, just gibberish back and forth.

Web Service Error 400 - Bad Request

Wanted to let you know this problem was solved. Another Dev that had worked on this service before but no longer just happened to walk by and I said "Hey! Look at this!"

They saw the garbage request data and said "That looks like compression. Look up compression in the project."

Turn out there was a custom compression component that was compressing the outgoing data of the service and you needed to add 2 lines of code to decompress. After adding those lines to the top of my method everything immediately worked.

The lesson here is if your project is doing some weird stuff that defies reason, try and find as many people as you can that worked on it before even if they aren't working on it anymore.



Related Topics



Leave a reply



Submit