August 2003
Intermediate to advanced
496 pages
11h 59m
English
Create a Web service with C# as project type, and enter http://localhost/Security/AppendixE/Calculator as the location of your project. Write a Web method named Calculator that accepts three arguments: first operand operation (+, - , *, /, Pow), second operand, and gives the result as double, as shown in the following code.
[WebMethod(Description="Simple Calculator Web Service.")]
public double Calculator(System.Double a,string c, System.Double b)
{
switch (c)
{
case "+":
return a + b;
case "-":
return a - b;
case "/":
if (b == 0)
{
return 0;
}
return a /b;
case "*":
return a * b;
case "Pow":
return Math.Pow(a, b);
default:
return 0;
}
}
Test the Web service in the test form and check the results. ...
Read now
Unlock full access