Beispiel #1
0
 static void Main(string[] args)
 {
     ServiceReference2.CalculatorClient client = new ServiceReference2.CalculatorClient();
     try
     {
         var result = client.Add(34, 20);
         Console.WriteLine(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult Index(double txtval1, double txtval2,
                           string add, string substract)
 {
     if (!string.IsNullOrEmpty(add))
     {
         BasicHttpBinding binding = new BasicHttpBinding();
         EndpointAddress  addr    = new EndpointAddress("http://localhost/WcfServiceCalculator/Calculator.svc");
         var client = new ServiceReference2.CalculatorClient(binding, addr);
         ViewBag.Message = "Result-Add: " + client.Add(txtval1, txtval2);
         return(View());
     }
     if (!string.IsNullOrEmpty(substract))
     {
         BasicHttpBinding binding = new BasicHttpBinding();
         EndpointAddress  addr    = new EndpointAddress("http://localhost/WcfServiceCalculator/Calculator.svc");
         var client = new ServiceReference2.CalculatorClient(binding, addr);
         ViewBag.Message = "Result-Substract: " + client.Subtract(txtval1, txtval2);
         return(View());
     }
     return(View());
 }