c# - WCF client request returns bad request (400) -


my client application use wcf web service hosted in local iis. web service use upload image. once image size become bigger gives bad request(400).

client configure dynamically web service url.

client code

string serviceurl=geturl();  /* http://localhost:85/imageuploaderservice.svc */  timespan timeout = new timespan(0, 30, 0);  endpointaddress endpoint = new endpointaddress(serviceurl);        basichttpbinding binding = new basichttpbinding() {     closetimeout = timeout,     maxreceivedmessagesize = 65536,     opentimeout = timeout,     receivetimeout = timeout,     sendtimeout = timeout,     maxbuffersize = 65536,     maxbufferpoolsize = 524288,     usedefaultwebproxy = true, };  binding.readerquotas = new system.xml.xmldictionaryreaderquotas() {     maxarraylength = 64000000,     maxstringcontentlength = 8192,     maxdepth = 32,     maxnametablecharcount = 16384,     maxbytesperread = 4096 };  client = new imageuploaderserviceclient(binding, endpoint);   

web service side

<basichttpbinding>     <binding maxbuffersize="64000000" maxreceivedmessagesize="64000000" maxbufferpoolsize="64000000">       <readerquotas maxdepth="64000000" maxstringcontentlength="64000000" maxarraylength="64000000" maxbytesperread="64000000" />       <security mode="none"/>     </binding>   </basichttpbinding>   

what wrong doing. please guide me through correct way.

you should increase maxreceivedmessagesize on client side probably:

basichttpbinding binding = new basichttpbinding() {      maxreceivedmessagesize = 64000000,      maxbuffersize = 64000000,      maxbufferpoolsize = 64000000, // ..... }; binding.readerquotas = new system.xml.xmldictionaryreaderquotas() {     maxarraylength = 64000000,     maxstringcontentlength = 64000000,     maxdepth = 64000000,     maxbytesperread = 64000000 }; 

i had same problem once - server , client binding configuration should same.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -