01: package demo.routing.client;
02:
03: import java.io.File;
04: import javax.xml.namespace.QName;
05: import javax.xml.ws.Service;
06: import org.objectweb.addnumbers.AddNumbers;
07: import org.objectweb.addnumbers.AddNumbersFault;
08:
09: public final class Client {
10: static QName serviceName = new QName(
11: "http://www.objectweb.org/addNumbers/types",
12: "AddNumbersXMLService");
13:
14: static QName portName = new QName(
15: "http://www.objectweb.org/addNumbers/types",
16: "AddNumbersPort");
17:
18: private Client() {
19: //Complete
20: }
21:
22: public static void main(String[] args) throws Exception {
23:
24: if (args.length == 0) {
25: System.err.println("please provide wsdl");
26: System.exit(0);
27: }
28:
29: File wsdl = new File(args[0]);
30:
31: Service service = Service.create(wsdl.toURL(), serviceName);
32: AddNumbers port = (AddNumbers) service.getPort(portName,
33: AddNumbers.class);
34:
35: try {
36: int number1 = 10;
37: int number2 = 20;
38:
39: System.out.printf("Invoking addNumbers(%d, %d)\n", number1,
40: number2);
41: int result = port.addNumbers(number1, number2);
42: System.out.printf(
43: "The result of adding %d and %d is %d.\n\n",
44: number1, number2, result);
45:
46: number1 = 3;
47: number2 = 5;
48:
49: System.out.printf("Invoking addNumbers(%d, %d)\n", number1,
50: number2);
51: result = port.addNumbers(number1, number2);
52: System.out.printf(
53: "The result of adding %d and %d is %d.\n\n",
54: number1, number2, result);
55:
56: number1 = -10;
57: System.out.printf("Invoking addNumbers(%d, %d)\n", number1,
58: number2);
59: result = port.addNumbers(number1, number2);
60: System.out.printf(
61: "The result of adding %d and %d is %d.\n", number1,
62: number2, result);
63: } catch (AddNumbersFault ex) {
64: System.out.printf("Caught AddNumbersFault: %s\n", ex
65: .getFaultInfo().getMessage());
66: }
67: System.exit(0);
68: }
69: }
|