Solved

web service 400 bad request with larger amount of data

Posted on 2011-09-04
9
2,099 Views
Last Modified: 2012-05-12
Ik get a 400 bad request messages when send a large XMLstring to a webservice.
I can send 32K of data just fine, but 64K return the 400 bad request warning.

Below I added a piece of the log. As you can see, it is possible to receive a larger amount of data from the webservice (761024 Bytes works just fine). The 167667 Bytes which is send causes the 400 message.

#Fields: sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken
200 0 0 3062 4249 2
200 0 0 761024 7261 15331
200 0 0 3062 4249 1
200 0 0 5714 7453 12154
200 0 0 3062 4249 2
200 0 0 1414 1373 0
200 0 0 3002 1302 0
200 0 0 7092 6570 1
400 0 0 159 167667 3
200 0 0 3062 4249 3

I have tried adding maxRequestBytes elements to the web.config, but that didn't solve the problem.

Currently this is the webservice part in my web.config
 <system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior name="ZPPort.IOBehavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
  <services>
   <service behaviorConfiguration="ZPPort.IOBehavior" name="ZPPort.IO">
    <endpoint address="" binding="wsHttpBinding" contract="ZPPort.IIO">
     <identity>
      <dns value="localhost" />
     </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>
 </system.serviceModel>

Open in new window


I run IIS 7.5.
0
Comment
Question by:Mattijs33
  • 5
  • 3
9 Comments
 
LVL 17

Expert Comment

by:Rovastar
ID: 36481583
Often the http.sys HTTP handler will capture the 400 http status codes before it reaches IIS.
Have a look also in the http.sys logs anyway.

default location: %windir%\System32\LogFiles\HTTPERR

IS there anything there?
What is the request you are sending? IS this all in the URL? IS it in the headers? Is all the 64K limit under one header?

0
 
LVL 17

Accepted Solution

by:
Rovastar earned 500 total points
ID: 36481693
I just remebered something else as you are talking about a service
MaxBufferSize and MaxReceivedMessageSize default to 64KB which is your problem amount
Try:
http://geekswithblogs.net/niemguy/archive/2007/12/11/wcf-maxstringcontentlength-maxbuffersize-and-maxreceivedmessagesize.aspx
0
 
LVL 4

Author Comment

by:Mattijs33
ID: 36483243
It seems that the wsHttpBinding has a physical limit of 64K, which can't be increased. I have changed the binding and everything works fine.
0
 
LVL 4

Author Comment

by:Mattijs33
ID: 36483850
I've requested that this question be closed as follows:

Accepted answer: 0 points for Mattijs33's comment http:/Q_27290792.html#36483243

for the following reason:

Found own solution.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 17

Expert Comment

by:Rovastar
ID: 36483847
No it doesn't have a limit of 64KB you can edit it the various parameters under it. That is what I said above.

Here is another link explain it with your 400 error in this.

http://fczaja.blogspot.com/2011/06/wcf-how-to-increase-allowed-request.html

I think it is wrong that your answer is marked correct.....
0
 
LVL 17

Expert Comment

by:Rovastar
ID: 36483851
No it doesn't have a limit of 64KB you can edit it the various parameters under it. That is what I said above.

Here is another link explain it with your 400 error in this.

http://fczaja.blogspot.com/2011/06/wcf-how-to-increase-allowed-request.html

I think it is wrong that your answer is marked correct.....
0
 
LVL 4

Author Comment

by:Mattijs33
ID: 36531450
wsHttpBinding with WS-ReliableMessaging on can't receive more than 64 K per message. You can find more information in this article http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
0
 
LVL 17

Expert Comment

by:Rovastar
ID: 36532194
You question was about wsHttpBinding and I stated that there are limits with that with the exact error you state.

The DEFAULT is 64K for the maxReceivedMessageSize is there for this as in the MS article from the link I had.

http://msdn.microsoft.com/en-us/library/ms731299.aspx

"maxBufferPoolSize
      
An integer that specifies the maximum buffer pool size for this binding. The default is 524,288 bytes (512 * 1024). Many parts of Windows Communication Foundation (WCF) use buffers. Creating and destroying buffers each time they are used is expensive, and garbage collection for buffers is also expensive. With buffer pools, you can take a buffer from the pool, use it, and return it to the pool once you are done. Thus the overhead in creating and destroying buffers is avoided.

maxReceivedMessageSize
      
A positive integer that specifies the maximum message size, in bytes, including headers, that can be received on a channel configured with this binding. The sender of a message exceeding this limit will receive a SOAP fault. The receiver drops the message and creates an entry of the event in the trace log. The default is 65536."

Personally i think you are moving the goalposts now with references to something you previously had no mentioned. Streaming with ws-reliable messing is a different case. I am not sure that article is even relevant/factually correct given how old it is, etc.

Mods can a subject matter expert on WCF look over this and make a decision.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now