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); } }
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(); }