public ConfigureApi() { Client = new apiSoapClient(); if(Client.State == CommunicationState.Closed) Client.Open(); _log.InfoFormat("Attempting to login to Lightstone Business APi using username {0} and password {1}", Username, Password); UserToken = Client.authenticateUser(Username, Password); }
public KBDAPIService(KBDAPIServiceConfig kbdServiceConfig, SearchServiceConfig searchServiceConfig) : base("[KBDAPIService]") { if (kbdServiceConfig == null || searchServiceConfig == null) { throw new Exception("Wrong application config file, it should have ServiceConfig parameters!"); } _searchServiceConfig = searchServiceConfig; /* BASIC HTTP CONTEXT BINDING */ BasicHttpContextBinding binding = new BasicHttpContextBinding(BasicHttpSecurityMode.TransportCredentialOnly); binding.Name = "KBDAPI_docsSoap"; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; string endpointAddress = $"http://{ kbdServiceConfig.ServiceUrl }/{ kbdServiceConfig.EndpointUrl}"; LOG_TRACE($"endpointAddress: {endpointAddress}"); EndpointAddress ea = new EndpointAddress(endpointAddress); _client = new KBDAPI_docsSoapClient(binding, ea); _client.ClientCredentials.UserName.UserName = "******"; _client.ClientCredentials.UserName.Password = "******"; if (searchServiceConfig == null) { LOG_ERROR($"SearchServiceConfig is null"); throw new Exception("Wrong applicaton config file, it should have SearchServiceConfig parameters!"); } BasicHttpContextBinding ssBinding = new BasicHttpContextBinding(BasicHttpSecurityMode.TransportCredentialOnly); ssBinding.Name = "apiSoap"; ssBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; string ssEndpointAddress = $"http://{searchServiceConfig.ServiceUrl}/{searchServiceConfig.EndpointUrl}"; EndpointAddress ssEa = new EndpointAddress(ssEndpointAddress); _searchClient = new apiSoapClient(ssBinding, ssEa); _searchClient.ClientCredentials.UserName.UserName = searchServiceConfig.Username; _searchClient.ClientCredentials.UserName.Password = searchServiceConfig.Password; _httpClient = new HttpClient(searchServiceConfig.ServiceUrl); }