Validation Application and WCF

Topics: Validation Application Block
Mar 10, 2009 at 5:40 PM
Hi there,

I am using Validation Application block with WCF. But when I try to call a method that does validation on the client I get the following message

The creator of this fault did not specify a Reason.

Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)



Here is my Interface

[

ServiceContract()]

 

[

ValidationBehavior]

 

 

public interface IBusinessUnit

 

{

[

OperationContract()]

 

 

BusinessUnit GetBusinessUnitByid(int id);

 

[

OperationContract()]

 

 

List<BusinessUnit> GetAllBusinessUnit();

 

[

OperationContract()]

 

[

FaultContract(typeof(ValidationFault))]
bool InsertBusinessUnit(BusinessUnit entity);

 

[

OperationContract()]

 

 

bool UpdateBusinessUnit(BusinessUnit entity);

 

[

OperationContract()]

 

 

bool DeleteBusinessUnit(int id);


Below is my implementation


 

 

public bool InsertBusinessUnit(BusinessUnit entity)

 

{

 

try

 

 

 

{

 

if (!this.Validate(entity))

 

{

 

return false;

 

}

 

ISingleResult<BusinessUnit> result = this.Context.PHIS_InsertBusinessUnits(entity.AddressLine1,

 

entity.AddressLine2,

entity.AdminPhone,

entity.AdminPhoneExt,

entity.City,

entity.Code,

 

this.ModifiedDate,

 

 

this.UserId,

 

entity.Description,

entity.EmergencyPhone1,

entity.EmergencyPhone2,

entity.EmergencyPhone2Ext,

entity.EmergencyPhone3,

entity.EmergencyPhone3Ext,

entity.EmergencyPhone1Ext,

entity.Fax,

entity.IsActive,

entity.MainPhone,

entity.MainPhoneExt,

entity.USStateId,

entity.PostalCode

);

 

 

 

if (result.Count() > 0)

 

{

 

return true;

 

}

 

return false;

 

}

 

catch (Exception ex)

 

{

 

Exception exceptionout = null;

 

 

ErrorHandling oErrorHandling = new ErrorHandling();

 

oErrorHandling.ProcessException(ex,

ExceptionPolicyType.ExceptionHandlePolicy, out exceptionout);

 

 

this.Options.ExceptionhandlingInstanceId = exceptionout.Message.ToString();

 

 

ValidationFault fault = new ValidationFault();

 

 

ValidationDetail detail = new ValidationDetail();

 

detail.Message = ex.Message.ToString();

fault.Add(detail);

 

FaultReason reason = new FaultReason(ex.Message.ToString());

 

 

throw new FaultException<ValidationFault>(fault);

 

 

//throw ex;

 

 

 

}

}

Mar 11, 2009 at 2:00 AM
Are you performing debugging when you encountered the error?  This may not be entlib-related issue, anyway, have a look at this thread - http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/cc65f4d6-2e5e-4e52-b828-2d509d8b1625/


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com