Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchService{T}"/> class.
 /// </summary>
 /// <param name="logger">The log handler for the controller.</param>
 /// <param name="serviceConfig">The service config settings <see cref="SearchServiceConfig"/></param>
 /// <param name="client">Interface to high level ElasticSearch client.</param>
 /// <param name="lowLevelClient">Interface to low level ElasticSearch client.</param>
 public SearchService(
     ILogger logger,
     SearchServiceConfig serviceConfig,
     IElasticClient client,
     IElasticLowLevelClient lowLevelClient)
 {
     _logger         = logger;
     _serviceConfig  = serviceConfig;
     _client         = client;
     _lowLevelClient = lowLevelClient;
 }
Exemplo n.º 2
0
        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);
        }