tags:

views:

201

answers:

1

Followup question to http://stackoverflow.com/questions/2502930/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
+1  A: 

Its hard to say without looking at the contract hierarchy of the service contract itself, but the answer may relys 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").
M.A. Hanin
The service contract itself is built as described in the linked thread. It's a ServiceContract inheriting multiple ServiceContracts. These base interfaces do not specify any callback contract. However, I could change that so that every required callback contract is used as a callback contract in one of the service contract base interfaces.
mafutrct
Question edited to show up the current design.
mafutrct
Try as you now edited, adding that [ServiceContract (CallbackContract = CallbackA)] for CallbackA and CallbackB.
M.A. Hanin
Ah, now I get the meaning of subinterface. Works perfectly now.
mafutrct