Allow FaultContractAttribute to be specified on a ServiceContract interface - by JocularJoe

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


7
0
Sign in
to vote
ID 343148 Comments
Status Closed Workarounds
Type Suggestion Repros 1
Opened 5/10/2008 3:11:16 AM
Access Restriction Public

Description

Currently if a client wants to be able to handle a custom FaultException, a FaultContract needs to be declared explicitly on each relevant method (OperationContract).  This is somewhat analagous to checked exceptions in java.

Suggest allowing FaultContract to be declared on a ServiceContract interface.
Sign in to post a comment.
Posted by JocularJoe on 2/25/2012 at 8:10 AM
Doesn't appear to have made it into 4.0 or 4.5 either. So I'm surprised it's closed as "Fixed".
Posted by Twan Jacobs on 3/24/2009 at 4:03 AM
Guess this didn't make it to wcf 3.5. Will this issue be resolved in version 4.0? I would opt for the interface level attributes ;-)
I've read suggestions to create an IContractBehavior that adds the service-wide faultcontracts. Unfortunately one would have to edit the ContractDescription, which would result in undefined execution behavior (according to the MSDN docs). Read all about this here:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/aa4ae2d9-5da3-4dea-acfb-81473bd69199/
Posted by JocularJoe on 5/17/2008 at 10:06 AM
That was of course meant to read as follows (two different FaultContracts):

[FaultContract(typeof(FaultDetail1))]
[FaultContract(typeof(FaultDetail2))]
public interface IServiceBase
{

}
... etc ...
Posted by JocularJoe on 5/17/2008 at 10:04 AM
An additional thought I had was that it would be even better to be able to inherit the FaultContract attribute from a base interface. In this way a FaultContract can be added to several ServiceContracts with one line of code.

I.e. in the following example both FaultContracts would apply to all operations of both IMyService1 and IMyService2:

[FaultContract(typeof(FaultDetail1))]
[FaultContract(typeof(FaultDetail1))]
public interface IServiceBase
{

}

[ServiceContract]
public interface IMyService1 : IServiceBase
{
... operations ...
}

[ServiceContract]
public interface IMyService2 : IServiceBase
{
... operations ...
}

Posted by Microsoft on 5/16/2008 at 12:32 PM
Hello JocularJoe,

Thanks for using WCF and submitting your feedback.

We had a brief internal conversation about your suggestion, and I logged a bug to consider adding this in the next release of WCF.

Thanks,
-Yavor Georgiev
Program Manager
Connected Framework Team
Posted by JocularJoe on 5/12/2008 at 1:28 PM
See also the following forum post:
http://forums.microsoft.com/forums/ShowPost.aspx?PostID=3329223&SiteID=1