/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:ClientInterpector.cs * 2.功能描述:客户端消息检查器 * 编辑履历: * 作者 日期 版本 修改内容 * 陈晓野 2014/08/13 1.00 新建 *******************************************************************************/ using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using Dongke.IBOSS.PRD.Basics.BaseResources; namespace Dongke.IBOSS.PRD.WCF.Proxys.ClientInterpector { /// /// 客户端消息检查器 /// public class ClientInterpector : IClientMessageInspector { /// /// 在收到回复消息之后将它传递回客户端应用程序之前,启用消息的检查或修改 /// /// 要转换为类型并交回给客户端应用程序的消息 /// 关联状态数据 public void AfterReceiveReply(ref Message reply, object correlationState) { } /// /// 在将请求消息发送到服务之前,启用消息的检查或修改 /// /// 要发送给服务的消息 /// 客户端对象通道 /// correlationState public object BeforeSendRequest(ref Message request, IClientChannel channel) { // 设置验证头信息 if (ProxySettings.LoginUserInfo != null) { request.Headers.Add(MessageHeader.CreateHeader(Constant.S_WCF_MESSAGE_HEADER_NAME, Constant.S_WCF_MESSAGE_HEADER_NAMESPACE, ProxySettings.LoginUserInfo)); } return null; } } }