private object GetWebServiceClientChannel( string sHostName, string sAppName, ITisWebServiceInfo oServiceInfo, string serviceInstanceName) { lock (this) { string webServiceUri = CreateWebServiceURI( sHostName, sAppName, oServiceInfo.ServiceName); TisWebServiceClient webServiceClient = GetWebServiceClientByUri(sAppName, webServiceUri); TisWebServiceContextData webServiceContextData = new TisWebServiceContextData() { Name = oServiceInfo.ServiceName, ApplicationName = sAppName, InstanceName = serviceInstanceName, CreatorTypeName = oServiceInfo.ServiceCreatorType, NodeName = Name, Version = ModuleVersion.PlatformVersion.ToString(), InstancePermission = GetInstancePermission(oServiceInfo, sAppName, StationName), StationName = StationName, StationId = StationId, UserName = UserName }; if (webServiceClient == null) { m_clientChannelFactoryConfiguration.EndPointConfigurationName = GetWebServiceConfigurationName(oServiceInfo); webServiceClient = new TisWebServiceClient( oServiceInfo.WebServiceContractType, m_clientChannelFactoryConfiguration, webServiceContextData, webServiceUri); m_cachedWebServiceClients.TryAdd(new TisWebServiceClientInfo(sAppName, webServiceUri), webServiceClient); } webServiceClient.Header = webServiceContextData; return(webServiceClient.ClientChannel); } }
private TisWebServiceClient GetWebServiceClientByUri( string applicationName, string webServiceUri) { TisWebServiceClient webServiceClient = null; var webServiceClientsInfo = (from webServiceClientInfo in m_cachedWebServiceClients.Keys where StringUtil.CompareIgnoreCase(webServiceClientInfo.ApplicationName, applicationName) && StringUtil.CompareIgnoreCase(webServiceClientInfo.WebServiceUri, webServiceUri) select webServiceClientInfo).FirstOrDefault(); if (webServiceClientsInfo != null) { m_cachedWebServiceClients.TryGetValue(webServiceClientsInfo, out webServiceClient); } return(webServiceClient); }