1 |
namespace MathService |
namespace MathService |
2 |
{ |
{ |
3 |
using System; |
using System; |
4 |
|
using System.Web.Services; |
5 |
using DotGNU.XmlRpc; |
using DotGNU.XmlRpc; |
6 |
|
|
7 |
[WebService(Description="A collection of math functions (From examples in CookComputing.XmlRpc)", Namespace="http://nfluid.com")] |
[WebService(Description="A collection of math functions (From examples in CookComputing.XmlRpc)", Namespace="http://nfluid.com")] |
10 |
public MathService() : base() {} |
public MathService() : base() {} |
11 |
|
|
12 |
[WebMethod("math.Add",Description="Add two integers and return the result")] |
[WebMethod("math.Add",Description="Add two integers and return the result")] |
13 |
public static int Add(int A, int B) |
public int Add(int A, int B) |
14 |
{ |
{ |
15 |
return A + B; |
return A + B; |
16 |
} |
} |
17 |
|
|
18 |
[WebMethod("math.Subtract", |
[WebMethod("math.Subtract", |
19 |
Description="Subtract one integer from another and return the result")] |
Description="Subtract one integer from another and return the result")] |
20 |
public static int Subtract(int A, int B) |
public int Subtract(int A, int B) |
21 |
{ |
{ |
22 |
return A - B; |
return A - B; |
23 |
} |
} |
24 |
|
|
25 |
[WebMethod("math.Multiply", |
[WebMethod("math.Multiply", |
26 |
Description="Multiply two integers and return the result")] |
Description="Multiply two integers and return the result")] |
27 |
public static int Multiply(int A, int B) |
public int Multiply(int A, int B) |
28 |
{ |
{ |
29 |
return A * B; |
return A * B; |
30 |
} |
} |
31 |
|
|
32 |
[WebMethod("math.Divide", |
[WebMethod("math.Divide", |
33 |
Description="Divide one integer by another and return the result. Returns Fault Response on divide by zero")] |
Description="Divide one integer by another and return the result. Returns Fault Response on divide by zero")] |
34 |
public static int Divide(int A, int B) |
public int Divide(int A, int B) |
35 |
{ |
{ |
36 |
if (B == 0) |
if (B == 0) |
37 |
{ |
{ |
38 |
throw new XmlRpcFaultException(1001, "Divide by zero"); |
throw new Exception("Divide by zero"); |
39 |
} |
} |
40 |
return A/B; |
return A/B; |
41 |
} |
} |