Not able to get Fault Exception Message using WCF and Validation Application Block EL 3.0

Topics: Exception Handling Application Block, Validation Application Block
Feb 6, 2008 at 7:19 AM
Edited Feb 6, 2008 at 11:26 AM
1 Defining Service Contracts and Service Implementation

ServiceContract(Namespace = "http://ServiceContracts/7/11",Name = "IServicePlanning", SessionMode = SessionMode.Allowed)

ValidationBehavior
public interface IServicePlanning
{
OperationContract
FaultContract(typeof(ValidationFault),Name="ValidationFault")
System.Int16 GetDetailsByProject(NotNullValidator
RangeValidator(1,RangeBoundaryType.Inclusive,System.Int64.MaxValue,RangeBoundaryType.Inclusive,MessageTemplate="Invalid ProjectID",Tag="",Negated=false)
System.Int64 request);

---- Service Implementation
ServiceBehavior
public class ServicePlanning : IServicePlanning
{
public System.Int16 GetDetailsByProject(System.Int64 projectID)
{
}


2) On the Client Side(UI Page) we are calling the Service as

try
{
ServicePlanningService.ServicePlanning oProxy= new ServicPlanningService.ServicePlanning();

int return = oProxy.GetQueueDetailsByProject(projectID);
}
catch (FaultException<ValidationFault> fault)
{

}
catch (FaultException ex)
{

}
catch (Exception ex2)
{

}
}

We expect the exception thrown by Validation application block to be captured as strongly typed exception FaultException<ValidationFault>.
But we get a SOAP exception which is captured in the generic catch block catch (Exception ex2)

The exception message says the following:

  • "The creator of this fault did not specify a reason" *

But the Detail section of the exception shows the validation fault details ("Invalid ProjectID")

We also tried setting the servicedebug attribute of servicebehavior in the host projects web.config
<serviceDebug includeExceptionDetailInFaults="true" />

Please suggest.