Validation App Block and Exception handling

Topics: Exception Handling Application Block, Validation Application Block
Jun 5, 2008 at 8:55 PM
Hi,

I am trying to use Validation app block to validate input/ out put parameters of a web method...

As long as Exception app block is not added in the config.. validation of input parameters is working fine ( I was not able to make output parameter validation work...) . It throws ValidationFaultException with required error message explaining about required range etc..

I added exception application block to config.. I am trying to handle exception of type System.Exception. I created ""Fault Contract Exception Handler" to throw a fault when some unhandled exception occur in my middle tier."Fault Contract Exception Handler" throws a pre defined fault exception ( say "AddErrorFault" )

Here is the siutation:

Invoking the service with the parameters with invalid range value ( expecting it to kick in WCF parameter validation)..

Service throws exception of type AddErrorFault ( I expected it to be ValidationFault) .. error.message does not have the required error message informing about the valid range for input parameters. error.message just says that "The creator of this fault did not specify a Reason".


any idea what went wrongh here??/

I am basically trying to integrae validation app block and exception handling block....


Jun 19, 2008 at 3:58 PM
Hi,

This thread might help you http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=25236

Fernando


msaivara wrote:
Hi,

I am trying to use Validation app block to validate input/ out put parameters of a web method...

As long as Exception app block is not added in the config.. validation of input parameters is working fine ( I was not able to make output parameter validation work...) . It throws ValidationFaultException with required error message explaining about required range etc..

I added exception application block to config.. I am trying to handle exception of type System.Exception. I created ""Fault Contract Exception Handler" to throw a fault when some unhandled exception occur in my middle tier."Fault Contract Exception Handler" throws a pre defined fault exception ( say "AddErrorFault" )

Here is the siutation:

Invoking the service with the parameters with invalid range value ( expecting it to kick in WCF parameter validation)..

Service throws exception of type AddErrorFault ( I expected it to be ValidationFault) .. error.message does not have the required error message informing about the valid range for input parameters. error.message just says that "The creator of this fault did not specify a Reason".


any idea what went wrongh here??/

I am basically trying to integrae validation app block and exception handling block....





Jul 2, 2008 at 7:16 PM
Hi,

I tried it, I was able to resolve the issue, I was able to bypass fault exception from Exception shielding...

For validation app block, I did not have anything in configuration.. adding validationbehavior attribute on Service interface.. and required validation attributes in properties in Data/ Message contracts...

Eventough I was able to see the details of the validation in  FaultException.Details.Message, I was trying to find a way to customize the FaultException.Message displayed.. currently it is displaying it as "The creator of this fault did not specify a Reason".

Any idea on how we can change the default message displayed...
Jul 2, 2008 at 7:36 PM
You can't change this message. The FaultException<> thrown by the ValidationParameterInspector is created supplying only the ValidationFault, so the default reason (ie "The creator of this fault...") is used. To change behavior this you'll need to change the source code.

Fernando

.

msaivara wrote:
Hi,

I tried it, I was able to resolve the issue, I was able to bypass fault exception from Exception shielding...

For validation app block, I did not have anything in configuration.. adding validationbehavior attribute on Service interface.. and required validation attributes in properties in Data/ Message contracts...

Eventough I was able to see the details of the validation in  FaultException.Details.Message, I was trying to find a way to customize the FaultException.Message displayed.. currently it is displaying it as "The creator of this fault did not specify a Reason".

Any idea on how we can change the default message displayed...