KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > handlers > server > AddNumbersImpl


1 package demo.handlers.server;
2
3 import javax.jws.HandlerChain;
4 import javax.jws.WebService;
5 import org.objectweb.handlers.AddNumbers;
6 import org.objectweb.handlers.AddNumbersFault;
7 import org.objectweb.handlers.types.FaultDetail;
8
9
10 @WebService(name = "AddNumbers", targetNamespace = "http://www.objectweb.org/handlers",
11             serviceName = "AddNumbersService",
12             wsdlLocation = "file:./wsdl/addNumbers.wsdl")
13 @HandlerChain(file = "../common/demo_handlers.xml", name = "DemoHandlerChain")
14 public class AddNumbersImpl implements AddNumbers {
15
16
17     /**
18      * @param number1
19      * @param number2
20      * @return The sum
21      * @throws AddNumbersException
22      * if any of the numbers to be added is negative.
23      */

24     public int addNumbers(int number1, int number2) throws AddNumbersFault {
25         System.out.println("addNumbers called....." + number1 + ":" + number2);
26         if (number1 < 0 || number2 < 0) {
27             String JavaDoc message = "Negative number cant be added!";
28             String JavaDoc detail = "Numbers: " + number1 + ", " + number2;
29             FaultDetail fault = new FaultDetail();
30             fault.setMessage(message);
31             fault.setFaultInfo(detail);
32             throw new AddNumbersFault(message, fault);
33         }
34         return number1 + number2;
35     }
36
37 }
38
Popular Tags