2011-09-16 5 views
3

"default"-faultcontract를 설정하는 방법이 있습니다. wcf-service-class의 모든 메소드에 대해? wcf-service에서 기본 faultcontract 속성을 설정하는 방법

[ServiceContract] 
[DefaultFaultContract(typof(MyServiceFault))] 
class MyService 
{ 
    [OperationContract] 
    void DoWork(); 
} 

대신

같은 :

[ServiceContract] 
public interface ICustomerService 
{ 
    [OperationContract] 
    [FaultContract(typeof(ServiceFault))] 
    void DoWork(); 
} 

나는 "단계별"가이드에 대한 링크를 주셔서 감사합니다.

답변

0

이이 작업을 수행 할 수있는 "오른쪽"방법이되지 않을 수도 있습니다,하지만 난 그냥 another question

This code might be usefull to you

에 대한 답변을 게시 그것은 개체의 멤버를 호출 할 때 발생한 모든 예외를 catch 프록시를 구축 특정 인터페이스를 구현합니다. wpf 채널에서 사용할 수 있습니다.

IMyInterface myService = [...]; 
IMyInterface myExceptionLoggedService = ExceptionProxyGenerator.Generate<IMyInterface>(myService); 
(myExceptionLoggedService as IExceptionProxy).Error+=(sender,method,exception)=>{ 
    // do what you want on exception 
}; 
// Use my service : 
myExceptionLoggedService.MyOkFunction();// ok 
myExceptionLoggedService.MyExceptionFunction();// calling the above delegate 

당신은 (이 결여 된 행동을 반환하지 않습니다 같은 오류에 대한 예외를 rethrowing과 기능 -if null을 반환하지 않습니다) 당신이 원하는 행동의 종류를 가지고 조금이 클래스를 다시 작성할 수

관련 문제