static void Main(string[] args) { BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = "KBDAPI_docsSoap"; binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; EndpointAddress ea = new EndpointAddress("http://89.109.33.138:1210/eda/KBDAPI_docs"); KBDAPI_docsSoapClient client = new KBDAPI_docsSoapClient(binding, ea); client.ClientCredentials.UserName.UserName = "******"; client.ClientCredentials.UserName.Password = "******"; try { client.Open(); var attributes = client.GetCardAttributes(); if (attributes != null) { foreach (var attr in attributes.item_CardAttribute) { Console.WriteLine($"{attr.title} : {attr.type}"); } } else { Console.WriteLine("Attributes is null"); } client.Close(); } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); if (ex.InnerException != null) { Console.WriteLine($"Inner Exception: {ex.InnerException.Message}"); } } Console.ReadLine(); }
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); }