JohnH.

Hi,

I am using my WCF web service. I set up my readerQoutas (attribute maxArrayLength) to 8388608 (8 MB). When someone sends file bigger than 8 MB, gets error message:

"An error occurred while making the HTTP request to .... This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. The underlying connection was closed: An unexpected error occurred on a send."

I would like to replace this default error with my own message, something like: "File bigger than 8 MB".

How can I do this

I would like to use some general way, because I would like to use my other own messages (for example "Bad certificate", "Too big attachment" etc.) and I would like to use XML as answer (somenthing like: <errors> <error>File too big</error> <errors> ... with other elements...)

Thanks,

John.




Re: Windows Communication Foundation (Indigo) WCF own error message

Dave Cliffe - MSFT

Hi John,

It sounds like what you want to do is to use a custom Fault Contract to generate your own Fault Exception. You can very easily manipulate the form of whatever fault you want to send back to the client over the wire. Check out this sample and let me know if this helps:

http://msdn2.microsoft.com/en-us/library/ms752208.aspx

-- Dave




Re: Windows Communication Foundation (Indigo) WCF own error message

Scott Seely

John and Dave,

That suggestion only applies if the message can get to the message handler. In John's case, the message will not get to the service because maxArrayLength for the ReaderQuotas will be exceeded and the throttling will not hand the message up the stack.

I'm pretty sure that you are going to wind up wrapping the underlying transport. When you see the byte limits exceeded, you can then send your custom Fault message stating that the max message receive side was exceeded.

FWIW, the exception you are seeing is due to a WebException being generated where the status is

WebExceptionStatus.SendFailure

Any text you are seeing is being generated on the client side at the moment.






Re: Windows Communication Foundation (Indigo) WCF own error message

JohnH.

Scott,

Than you for your answer. Yes, this is the solution what I am looking for (my message can¡¯t get to the message handler), but could you write some details or simple example, please

I understood to your answer like that: I must remove the check up from web.config (maybe remove the maxArrayLength control in web,config) and I must give this check up to my code (here I can throw my own Fault message). Is it correct In this case my web service can accept big messages (until this size will be ckecked) and channel loading will be enormous maybe. Or channel loading is equal when I control size of message in web.config Is this only solution when I want to overlay client-side messages Can¡¯t I use some elements in web config that can help me to get the message handler or something like that

Thanks,

John.






Re: Windows Communication Foundation (Indigo) WCF own error message

JohnH.

...and one complement: I removed maxArrayLength from config files, but WCF didn¡¯t allow to send bigger files. So I can¡¯t get to the message handler. So my problem is maybe bigger Smile

Thanks,






Re: Windows Communication Foundation (Indigo) WCF own error message

Scott Seely

The channel is probably being closed as a result of the receive-side channel transitioning to the Faulted state. You would need to write something that got involved in the channel creation steps (probably a BindingElement + Listener Factory + Listener + Channel).

My main concern here is that the behavior you are seeing-- message conversation terminated due to excessive size -- is meant to protect your endpoint. I think this particular limitation will be very difficult to work around.






Re: Windows Communication Foundation (Indigo) WCF own error message

JohnH.

OK,

I shall try this solution, although I dont know if this will be the best solving (but I think it is only solving).

Thank you.






Re: Windows Communication Foundation (Indigo) WCF own error message

Yavor Georgiev - MSFT

Hi John,

Did Scott's input help resolve your problem

Thanks,

-Yavor





Re: Windows Communication Foundation (Indigo) WCF own error message

JohnH.

Hi Yavor,
Scott¡¯s answer is good, I used this way: I control size on the client side, and on the server side too. If file is too big, client program generate answer before sending. If client program has some problem and don¡¯t catch big files, WCF throw standard exception (just for sure - double control).

John.