Example #1
0
        static async Task CreateAndCallClient()
        {
            using (var echoClient = new EchoServiceClient("EchoService"))
            {
                echoClient.ClientCredentials.UserName.UserName = @"username";
                echoClient.ClientCredentials.UserName.Password = @"password";

                // Don't validate certificates since they're just for test purposes
                echoClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

                echoClient.Open();

                Console.WriteLine(await echoClient.SendStringAsync("Test12345"));
            }
        }
Example #2
0
        private static async Task CreateAndCallClient()
        {
            // Cache the WCF client so that its ChannelFactory is reused.
            // This sort of caching (reusing channel factory) happens automatically
            // in NetFx when using config-based clients. In NetCore, though, users
            // will need to manage this themselves to keep good performance.
            if (EchoServiceClient == null)
            {
                EchoServiceClient = new EchoServiceClient(GetBinding(), Endpoint);
                EchoServiceClient.ClientCredentials.UserName.UserName = @"username";
                EchoServiceClient.ClientCredentials.UserName.Password = @"password";

                // Don't validate certificates since they're just for test purposes
                EchoServiceClient.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication()
                {
                    CertificateValidationMode = X509CertificateValidationMode.None,
                    RevocationMode            = X509RevocationMode.NoCheck
                };
            }

            Console.WriteLine(await EchoServiceClient.SendStringAsync("TestABCDEF"));
        }