01: package demo.handlers.server;
02:
03: import javax.jws.HandlerChain;
04: import javax.jws.WebService;
05: import org.objectweb.handlers.AddNumbers;
06: import org.objectweb.handlers.AddNumbersFault;
07: import org.objectweb.handlers.types.FaultDetail;
08:
09: @WebService(name="AddNumbers",targetNamespace="http://www.objectweb.org/handlers",serviceName="AddNumbersService",wsdlLocation="file:./wsdl/addNumbers.wsdl")
10: @HandlerChain(file="../common/demo_handlers.xml",name="DemoHandlerChain")
11: public class AddNumbersImpl implements AddNumbers {
12:
13: /**
14: * @param number1
15: * @param number2
16: * @return The sum
17: * @throws AddNumbersException
18: * if any of the numbers to be added is negative.
19: */
20: public int addNumbers(int number1, int number2)
21: throws AddNumbersFault {
22: System.out.println("addNumbers called....." + number1 + ":"
23: + number2);
24: if (number1 < 0 || number2 < 0) {
25: String message = "Negative number cant be added!";
26: String detail = "Numbers: " + number1 + ", " + number2;
27: FaultDetail fault = new FaultDetail();
28: fault.setMessage(message);
29: fault.setFaultInfo(detail);
30: throw new AddNumbersFault(message, fault);
31: }
32: return number1 + number2;
33: }
34:
35: }
|