01: package com.mycompany.example1;
02:
03: import org.xins.common.service.TargetDescriptor;
04: import org.xins.common.http.HTTPMethod;
05:
06: import com.mycompany.myproject.capi.CAPI;
07: import com.mycompany.myproject.types.Gender;
08:
09: /**
10: * Simple program that invoke MyFunction
11: */
12: public class TestMyFunction {
13:
14: /**
15: * Invokes MyFunction
16: *
17: * @param args
18: * optional parameters: args[0] is the URL, args[1] is the gender(m/f) and
19: * args[2] is the last name.
20: */
21: public final static void main(String[] args) throws Exception {
22:
23: String targetURL = "http://127.0.0.1:8080/myproject/";
24: if (args.length > 0) {
25: targetURL = args[0];
26: }
27:
28: Gender.Item gender = Gender.MALE;
29: if (args.length > 1) {
30: gender = Gender.getItemByName(args[1]);
31: }
32:
33: String lastName = "Lee";
34: if (args.length > 2) {
35: lastName = args[2];
36: }
37:
38: // Create the descriptor for the service with a time-out of 20 seconds
39: TargetDescriptor descriptor = new TargetDescriptor(targetURL,
40: 20000);
41:
42: // Create the CAPI instance
43: CAPI project = new CAPI(descriptor);
44:
45: // Invoke the function
46: String message = project.callMyFunction(gender, lastName)
47: .getMessage();
48:
49: // No exceptions thown
50: System.out.println("Call successful. Message: " + message);
51: }
52: }
|