// 获得一个AppServer服务器提供的远程对象 // 入口参数: // Type interfaceType 接口类型 public static object GetAppSvrObj(Type interfaceType) { // 目前发现有时候如果服务器端抛出异常,客户端截获后, 当前线程的CallContext会丢失 // 由于目前目前程序是将用户当前身份放在CallContext中的, 所以导致问题 // 因此,在下面的代码中添加一行,每次GetAppSvrObj的时候强制将当前用户身份设置到CallContext中 // 此方案要求每次用户调用remoteObj之前都必须调用GetAppSvrObj,而不能GetAppSvrObj之后长期使用 RemotingUserCTX.SetCurUser(SessionClass.CurrentSinoUser); if (ConfigFile.ICS_Channel == Config_IcsChannel.Tcp) { return(RemotingUtils.GetObject(interfaceType, ConfigFile.ICS_UriPrefix_TCP)); } else { return(RemotingUtils.GetObject(interfaceType, ConfigFile.ICS_UriPrefix_HTTP)); } }
// 注册一个基于接口实现的Single Call Remoting Service, 为Client服务 // 入口参数: // Type interfaceType 接口类型 // Type bizLogicClassType 实现该接口的业务逻辑类 public static void RegisterService(Type interfaceType, Type bizLogicClassType) { RemotingUtils.RegisterSingleCallService(interfaceType, bizLogicClassType); }