//private static IStateService clientStateService; //static WcfServiceClientFactory() //{ // clientStateService = AppInfoCenterService.StateService; // clientStateService.Init(new StateServiceConfiguration(typeof(WcfClientStateInfo).FullName, WcfClientStateService.GetState)); //} private static ChannelFactory <T> CreateChannelFactory <T>(WcfClientEndpointConfig endpoint) { if (endpoint == null) { throw new Exception("不能找到Wcf客户端配置,请检查配置数据库!"); } try { var binding = ConfigHelper.CreateBinding(endpoint.EndpointBindingType, endpoint.EndpointBindingXml); if (binding is NetNamedPipeBinding) { endpoint.EndpointAddress = "localhost"; } var address = ConfigHelper.CreateAddress(endpoint.EndpointProtocol, endpoint.EndpointAddress, endpoint.EndpointPort, endpoint.EndpointName); var factory = new ChannelFactory <T>(binding, address); factory.Endpoint.Behaviors.Add(new MessageInspectorEndpointBehavior()); if (!string.IsNullOrEmpty(endpoint.EndpointBehaviorXml)) { AddEndpointBehavior(factory, endpoint.EndpointBehaviorXml); } return(factory); } catch (Exception ex) { ex.Handle(WcfLogProvider.ModuleName, "WcfServiceClientFactory", "CreateChannelFactory"); throw; } }
internal static ClientStartInfo GetClientStartInfo( string contractName, string extraInfo, WcfClientEndpointConfig endpoint) { var log = GetStartInfo <ClientStartInfo>(extraInfo); log.ContractName = contractName; log.WcfEndpoint = endpoint; return(log); }