• WCF学习笔记三:使用自定义行为扩展WCF总结


    服务站: 使用自定义行为扩展 WCF文中详细的描述了自定义行为扩展点,下面对这些扩展点的扩展方法进行总结

    调度程序扩展点
    1、消息检查:EndpointDispatcher.DispatchRuntime.MessageInspectors.Add(IDispatchMessageInspector);
    2、操作选择器:EndpointDispatcher.DispatchRuntime.OperationSelector = IDispatchOperationSelector;
    3、消息格式化(反序列化):DispatchOperation.Formatter = IDispatchMessageFormatter;
    4、参数检查:DispatchOperation.ParameterInspectors.Add(IparameterInspector);
    5、操作调用程序:DispatchOperation.Invoker = IOperationInvoker;

    获取DispatchRuntime实例的几种方式【DispatchRuntime 类

    a、在ServiceHost中

    foreach (ChannelDispatcher cDispatcher in host.ChannelDispatchers)
    foreach (EndpointDispatcher endpointDispatcher in cDispatcher.Endpoints)
    endpointDispatcher.DispatchRuntime...

    b、在IServiceBehavior接口的ApplyDispatchBehavior中

    public void ApplyDispatchBehavior(ServiceDescription serviceDescription,

    System.ServiceModel.ServiceHostBase serviceHostBase)
    {
    foreach (ChannelDispatcher cDispatcher in serviceHostBase.ChannelDispatchers)
    foreach (EndpointDispatcher endpointDispatcher in cDispatcher.Endpoints)
    endpointDispatcher.DispatchRuntime...
    }

    c、在IEndpointBehavior接口的ApplyDispatchBehavior中

    public void ApplyDispatchBehavior(ServiceEndpoint endpoint,

    System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
    {
    endpointDispatcher.DispatchRuntime...
    }

     
    d、在IContractBehavior接口的ApplyDispatchBehavior中

    public void ApplyDispatchBehavior(ContractDescription contractDescription,

    ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
    {
    dispatchRuntime...
    }

     获取DispatchOperation实例的几种方式【DispatchOperation类
    a、在IOperationBehavior接口的ApplyDispatchBehavior中

    public void ApplyDispatchBehavior(OperationDescription operationDescription,

    System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
    {
    dispatchOperation...
    }

     
    b、在DispatchRuntime实例中

    foreach (DispatchOperation dispatchOperation in DispatchRuntime.Operations)
    dispatchOperation...


    代理(客户端)扩展点
    1、参数检查:ClientOperation.ParameterInspectors.Add(IparameterInspector);
    2、消息格式化(序列化):ClientOperation.Formatter = IClientMessageFormatter;
    ?、操作选择器:ClientRuntime.OperationSelector = IClientOperationSelector;
    3、消息检查:ClientRuntime.MessageInspectors.Add(IClientMessageInspector);

    获取ClientRuntime实例的几种方式【ClientRuntime类
    a、在IEndpointBehavior接口的ApplyClientBehavior中

    public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
    {
    clientRuntime...
    }

     
    b、在IContractBehavior接口的ApplyClientBehavior中

    public void ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint

    endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
    {
    clientRuntime...
    }

    获取ClientOperation实例的几种方式【ClientOperation类
    a、在IOperationBehavior接口的ApplyClientBehavior中

    public void ApplyClientBehavior(OperationDescription operationDescription,

    System.ServiceModel.Dispatcher.ClientOperation clientOperation)
    {
    clientOperation...
    }


    b、在ClientRuntime实例中

    foreach(ClientOperation clientOperation in ClientRuntime.Operations)
    clientOperation...


    I...Behavior添加到ServiceHost中的方法
    1、IServiceBehavior

    ServiceHost.Description.Behaviors.Add(IServiceBehavior);


    2、IEndpointBehavior

    foreach (ServiceEndpoint endpoint in ServiceHost.Description.Endpoints)
    {
    endpoint.Behaviors.Add(IEndpointBehavior);
    }


    3、IContractBehavior

    foreach (ServiceEndpoint endpoint in ServiceHost.Description.Endpoints)
    {
    endpoint.Contract.Behaviors.Add(IContractBehavior);
    }


    4、IOperationBehavior

    foreach (ServiceEndpoint endpoint in ServiceHost.Description.Endpoints)
    {
    foreach (OperationDescription operationDescription in endpoint.Contract.Operations)
    {
    operationDescription.Behaviors.Add(IOperationBehavior);
    }
    }

    I...Behavior添加到Client的Endpoint中的方法
    1、IEndpointBehavior

    Endpoint.Behaviors.Add(IEndpointBehavior);


    2、IContractBehavior

    Endpoint.Contract.Behaviors.Add(IContractBehavior);


    3、IOperationBehavior

    foreach (OperationDescription operationDescription in Endpoint.Contract.Operations)
    {
    operationDescription.Behaviors.Add(IOperationBehavior);
    }


    获取Client的Endpoint的方法:
    1、ClientBase.Endpoint
    2、ChannelFactory.Endpoint

  • 相关阅读:
    jsp页面跳转的路径问题
    Hibernate简单的保存操作
    Hibernate中如何完成持久化类和数据库映射文件
    spring中IOC的简单使用
    对称的二叉树 --剑指offer
    二叉树的下一个结点 --剑指offer
    删除链表中重复的结点 --剑指offer
    链表中环的入口结点 --剑指offer
    字符流中第一个不重复的字符 --剑指offer
    表示数值的字符串 --剑指offer
  • 原文地址:https://www.cnblogs.com/xujiaoxiang/p/1750726.html
Copyright © 2020-2023  润新知