我有如下服务合同
[ServiceContract]
public interface IService
{
[MyCustomBehavior]
[OperationContract]
void MyOperation();
}问题是,调用
new ChannelFactory<IService>(myBinding, myUri)是否会隐式地在调用前添加MyCustomBehavior,仅仅因为我将IService传递给ChannelFactory,还是需要更深入地挖掘并显式地将MyCustomBehavior设置为MyOperation操作?
发布于 2012-05-20 08:53:12
操作行为
实现IOperationBehavior接口的操作行为用于扩展每个操作的客户端和服务运行时。
有两种机制可以将操作行为添加到操作中。第一种机制是创建一个自定义属性,用于对操作建模的方法。向ServiceHost或ChannelFactory添加操作时,WCF会将任何IOperationBehavior属性添加到为该操作创建的OperationDescription上的behaviors集合。
第二种机制是通过将行为直接添加到构造的OperationDescription上的behaviors集合。
我建议你先读这篇文章。
Configuring and Extending the Runtime with Behaviors
https://stackoverflow.com/questions/10669914
复制相似问题