How to Implement Fault Contracts in Callback Functions

- J.D. Meier, Carlos Farre, Jason Taylor, Prashant Bansode, Steve Gregersen, Madhu Sundararajan, Rob Boucher

In duplex bindings you need to implement the service with a callback contract specifying the interface so the client can implement it. Use the CallbackContract attribute in the service contract to specify the type of callback contract which has the callback function.

The following code example shows a service that specifies a callback contract:
[ServiceContract(CallbackContract = typeof(IMyContractCallback))]
interface IMyContract
{
   [OperationContract]
   void DoSomething( );
}
interface IMyContractCallback
{
   [OperationContract]
   [FaultContract(typeof(InvalidOperationException))]
   void OnCallBack( );
}

Additional Resources

Last edited Jun 13, 2008 at 6:46 PM by prashantbansode, version 1

Comments

No comments yet.