views:

379

answers:

3

I've got a WCF service that is working for basic queries. I started with simply the default out of the box bindings (WSHttpBinding with default values).

The data-contract is for an array of custom objects, each object comes to about 6k in size. When I send up to 5 of these (in a single transaction), it works fine. When I attempt to send 6 or more, I get this error:

"The remote server returned an error: (400) Bad Request."

I researched bindings some, and tried setting the configurations on the client like this:

<binding name="WSHttpBinding_IASRService" closeTimeout="00:10:00"
         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
         bypassProxyOnLocal="false" transactionFlow="false" 
         hostNameComparisonMode="StrongWildcard"
         maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
         messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
         allowCookies="false">
   <readerQuotas maxDepth="50000000" maxStringContentLength="50000000" 
                 maxArrayLength="50000000" maxBytesPerRead="50000000" 
                 maxNameTableCharCount="50000000" />
   <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
</binding>

I similarly set the configurations on the services web.config file, however, the problem still persists.

I also tried to set the client app.config to messageEncoding="Mtom", but that generated another binding error, saying the bindings may be mismatched between client and server, so I took that out for now. (Although Mtom was also specified at the server web.config.) Also, in my research, I have not yet found a clear simple description of each of the binding properties.

In summary, I'm trying to answer the following questions:

  1. How to get larger requests to not generate the bad request error
  2. How to set client to Mtom without generating error
  3. Is there a good basic reference on each of the binding properties and how to use them?
+1  A: 

Your best bet for getting started debugging, would be to take an operational approach. I'd pull out Fiddler, and make sure the the client is sending a valid request.

Jason Watts
+2  A: 

Here's a tip i learned the hard way for your #2:

Every time you make a change to WCF on the server side, recompile the server project then "Update Reference" on the client side (right click service reference).

vidalsasoon
Would this apply to just changing the server side web.config file?
alchemical
Yes if you're changing sections involving the WCF params
vidalsasoon
A: 

I finally figured this out!

On SO of all places, see this question

That solved my main issue (#1). I'm still looking for a clear description of how to configure the various binding WCF properties. I've looked online, in books, and at the API docs at MSDN. If anyone knows of something that really spells it out, please post it here. It seems like WCF is fairly straight forward, until you get into the binding details.

alchemical