Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a WCF contract use multiple callback interfaces?

Tags:

.net

wcf

I'm trying something like this:

[ServiceContract (
    CallbackContract = typeof (CallbackContract_1),
    CallbackContract = typeof (CallbackContract_2),
    CallbackContract = typeof (CallbackContract_3))
]
public interface SomeWcfContract {

I know it does not work like this. Is there still a way to get a single contract use multiple callback interfaces?

like image 250
mafu Avatar asked Mar 23 '10 22:03

mafu


1 Answers

A service contract can only designate a callback contract if that contract is a subinterface of all callback contracts defined by the contract's own base contracts.

interface ICallbackContract1
{...}

interface ICallbackContract2 : ICallbackContract1
{...}

[ServiceContract(CallbackContract = typeof(ICallbackContract1))]
interface IMyBaseContract
{...}

[ServiceContract(CallbackContract = typeof(ICallbackContract2))]
interface IMySubContract : IMyBaseContract
{...}

or

interface ICallbackContract1
{...}
interface ICallbackContract2
{...}
interface ICallbackContract3 : ICallbackContract2,ICallbackContract1
{...}

[ServiceContract(CallbackContract = typeof(ICallbackContract1))]
interface IMyBaseContract1
{...}
[ServiceContract(CallbackContract = typeof(ICallbackContract2))]
interface IMyBaseContract2
{...}
[ServiceContract(CallbackContract = typeof(ICallbackContract3))]
interface IMySubContract : IMyBaseContract1,IMyBaseContract2
{...}

see for more details

like image 61
garik Avatar answered Sep 18 '22 20:09

garik