我知道此服务中的所有操作都需要相同的OperationBehavior。在运行操作之前,我是否可以实现一个执行相同功能的ServiceBehavior?
我目前有:
[ServiceContract]
public interface IService
{
[AuthTokenValidation]
[OperationContract]
string DoThis(string authtoken);
}我想将其替换为:
[AuthTokenValidation]
[ServiceContract]
public interface IService
{
[OperationContract]
string DoThis(string authtoken);
}在我的AuthTokenValidation属性中,我的ApplyDispatchBehavior方法中有以下代码:
public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
{
AuthTokenInspector inspector;
inspector = new AuthTokenInspector(AuthTokenIndex);
dispatchOperation.ParameterInspectors.Add(inspector);
}我检查了IServiceBehavior中的ApplyDispatchBehavior方法,但我不知道如何访问当前正在调用的DisppatchOperation。
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
//Can I reach the OperationDispatch from in here??
}这是使用ServiceBehavior的正确方式吗?或者我应该仅仅满足于使用OperationBehaviors来实现此功能?
发布于 2010-11-10 03:05:28
我没有尝试过,但我认为你可以像下面这样访问你的DispatchOperation:
https://stackoverflow.com/questions/4137108
复制相似问题