tags:

views:

137

answers:

1

I want to set the MaxReceivedMessageSize property to some higher limit (Due to (400) Bad Request error) in my client programatically. This is the code I am using...

WCFServiceTestClient wcfClient = 
    new WCFServiceTestClient(new wsHttpBinding(), strServiceURL);

My service url is dynamic and hence cannot use the web.config.

//The following code doesnt seem to take effect
((WSHttpBinding)wcfClient.ChannelFactory.Endpoint.Binding)
        .MaxReceivedMessageSize = 2147483647;

What am I doing wrong?
Any help is appreciated.
Thanks
Pratt

+1  A: 

Have you tried re-ordering the calls so that you set the MaxReceivedMessageSize before instantiating the client? eg,

var binding = new wsHttpBinding();
binding.MaxReceivedMessageSize = Int32.MaxValue; 
var wcfClient = new WCFServiceTestClient(binding, strServiceURL); 

This may or may not help your 400 error, though.

Cheeso