开发者

Can I compose a WCF callback contract out of multiple interfaces?

Followup question to How can I compose a WCF contract out of multiple interfaces?.

I tried to merge multiple callback interfaces in a single interface. This yields an InvalidOperationException claiming that the final interface contains no operations. Technically, this is true, however, the inherited interfaces do contain operations.

How can I fix this? Or is this a limitation of WCF?

Edit:

[ServiceContract]
// Using the following line instead would be no problem for me:
// [ServiceContract (CallbackContract = CallbackA)]
interface ServiceA { [OperationContract]void X(); }

[ServiceContract] // same here
interface ServiceB { [OperationContract]void Y(); }

interface CallbackA { [OperationContract]void CB_开发者_开发知识库A() } // required in ServiceA
interface CallbackB { [OperationContract]void CB_B() } // required in ServiceB

interface CallbackC: CallbackA, CallbackB {} // composed callback contract

[ServiceContract (CallbackContract = CallbackC)]
interface ServiceC: ServiceA, ServiceB {} // composed service contract


Its hard to say without looking at the contract hierarchy of the service contract itself, but the answer may rely on this principle:

"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."

  • (Programming WCF Services, O'Reilly, see here under "Callback Contract Hierarchy").
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜