简体   繁体   English

WCF-回调接口可以指定为通用接口吗?

[英]WCF - Can the callback interface specified as a generic one?

Consider that I am gonna create one generic interface for subscribing and unsubscribing to a duplex service, for ex: 考虑一下,我将创建一个通用接口,用于订阅和取消订阅双工服务,例如:

[servicecontract(CallbackContract=typeof(ICallbackService))]
public interface IService
{
 [operationcontract]
 void sub();
 [operationcontract]
 void unsub();
}

public interface ICallbackService
{
[operationcontract(isoneway=true)]
void senddata(object data);
}

public interface IFirstService:IService{}
public interface ISecondService:IService{}

And on the client side while creating duplex channel instance, i have my callback instance as 在客户端上创建双工通道实例时,我的回调实例为

class callbackclass:ICallbackService{
public void senddata(object d){}
}

and when using 当使用

DuplexChannelFactory<IFirstService> fact=new DuplexChannelFactory<IFirstService>(new instancecontext(new callbackclass()),new wsdualhttpbinding(),"address");
var chan=fact.CreateChannel();

I am facing a issue saying the contract IFirstService doesnt define any operations.Can any one help with this kind of scenario. 我遇到一个问题,说合同IFirstService没有定义任何操作。任何人都可以帮助解决这种情况。

Unfortunately you can't. 不幸的是你不能。 It's not possible to do that, as soap does not support this. 不可能这样做,因为肥皂不支持这一点。 Please read this article . 请阅读这篇文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM