Exemple #1
0
        private void InitializeClient()
        {
            if (this.client == null)
            {
                this.client = new ServiceReference1.CalculatorClient();
                BasicHttpBinding binding = this.client.Endpoint.Binding as BasicHttpBinding;
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                //client.ClientCredentials.UserName.UserName = "******";
                //client.ClientCredentials.UserName.Password = "******";

                this.client.Endpoint.Behaviors.Remove <ClientCredentials>();
                this.client.Endpoint.Behaviors.Add(new ClientCredentialsEx(this));
            }
        }
Exemple #2
0
        private void btnhosting_Click(object sender, EventArgs e)
        {
            int n  = int.Parse(txtnum1.Text);
            int n1 = int.Parse(txtnum2.Text);

            try
            {
                ServiceReference1.CalculatorClient cc = new ServiceReference1.CalculatorClient();
                var Add = cc.Add(n, n1);
                var Sub = cc.Sub(n, n1);
                MessageBox.Show("Addition:" + Add);
                MessageBox.Show("Subtraction:" + Sub);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnIIS_Click(object sender, EventArgs e)
        {
            int n  = int.Parse(txtNum1.Text);
            int n1 = int.Parse(txtNum2.Text);

            try
            {
                ServiceReference1.CalculatorClient cc = new ServiceReference1.CalculatorClient(); // interface cant create object soooo Google

                var add = cc.Add(n, n1);
                var sub = cc.Sub(n, n1);

                MessageBox.Show("Addition : " + add);
                MessageBox.Show("Subtraction : " + sub);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press enter to call the service");
            Console.ReadLine();

            var proxy = new ServiceReference1.CalculatorClient("BasicHttpEndpoint");

            proxy.ClientCredentials.UserName.UserName = "******";
            proxy.ClientCredentials.UserName.Password = "******";


            var arguments = new ServiceReference1.Arguments();

            arguments.Arg1 = 1;
            arguments.Arg2 = 2;

            var result = proxy.Add(arguments);

            Console.WriteLine("Result: " + result.Value);
            Console.WriteLine("Press enter to close the application :)");
            Console.ReadLine();
        }