WCF和多个回调合同成为可能

时间:2012-10-28 16:31:05

标签: wcf

我是WCF中的新手。我正在寻找多个回调合约的出路可能或不像下面

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

我正在搜索谷歌并找到出路就像

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
{...}

我只需要知道多个回调合约还有其他出路吗?感谢

1 个答案:

答案 0 :(得分:0)

单个服务合同不能有多个回调合约(它是1:1的关系,回调合约可以为null)。正如你所发现的,那个替代方案(使用多个“前向”合同,每个都有自己的回调合同)应该可以工作,虽然我没有尝试过(你可以编写一个简单的程序来测试)。