public static void AddCCWServiceClient(this IServiceCollection services, IConfiguration config)
        {
            services.AddSingleton <CVSECommonClient>(provider =>
            {
                var username   = config.GetValue <string>("CCW_USER_ID");
                var password   = config.GetValue <string>("CCW_PASSWORD");
                var url        = config.GetValue <string>("CCW_ENDPOINT_URL");
                var appId      = config.GetValue <string>("CCW_APP_ID");
                var batchUser  = config.GetValue <string>("CCW_USER_ID");
                var batchAppId = config.GetValue <string>("CCW_BATCH_APP_ID");

                var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                binding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.Basic;

                var client = new CVSECommonClient(EndpointConfiguration.CVSECommon);
                client.ClientCredentials.UserName.UserName = username;
                client.ClientCredentials.UserName.Password = password;
                client.Endpoint.Binding = binding;
                client.Endpoint.Address = new EndpointAddress(url);

                client.BatchAppId = batchAppId;
                client.AppId      = appId;
                client.BatchUser  = batchUser;

                return(client);
            });

            services.AddSingleton <ICCWService, CCWService>();
        }
Exemple #2
0
        public CCWService(string endpointURL, string applicationIdentifier, string basicAuth_username, string basicAuth_password)
        {
            this.endpointURL           = endpointURL;
            this.applicationIdentifier = applicationIdentifier;
            this.basicAuth_username    = basicAuth_username;
            this.basicAuth_password    = basicAuth_password;

            this.Client = new CVSECommonClient(GetBinding(), new EndpointAddress(this.endpointURL));

            this.Client.ClientCredentials.UserName.UserName = this.basicAuth_username;
            this.Client.ClientCredentials.UserName.Password = this.basicAuth_password;
        }
Exemple #3
0
 public CCWService(CVSECommonClient client, ILogger <CVSECommonClient> logger)
 {
     _client = client;
     _logger = logger;
 }