1
2
3
4
5
6
7
8
9 package bexee.ant;
10
11 import java.rmi.RemoteException;
12
13 import javax.xml.rpc.ParameterMode;
14 import javax.xml.rpc.ServiceException;
15
16 import org.apache.axis.client.Call;
17 import org.apache.axis.client.Service;
18 import org.apache.axis.encoding.XMLType;
19 import org.apache.tools.ant.BuildException;
20 import org.apache.tools.ant.Task;
21
22 /***
23 * Starts a BPEL process on bexee.
24 * <p>
25 * Note that this Task is very primitive and supports only service operations
26 * that take a string parameter as input and return a string. It is only used
27 * for simple demonstration purposes.
28 *
29 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:17 $
30 * @author Patric Fornasier
31 * @author Pawel Kowalski
32 */
33 public class StartTask extends Task {
34
35 private String url;
36
37 private String operation;
38
39 private String input;
40
41 /***
42 * Location of the BPEL process Web Service.
43 *
44 * @param url
45 * a <code>URL</code>
46 */
47 public void setUrl(String url) {
48 this.url = url;
49 }
50
51 /***
52 * Name of the operation to perform
53 *
54 * @param operation
55 * a <code>String</code>
56 */
57 public void setOperation(String operation) {
58 this.operation = operation;
59 }
60
61 /***
62 * The input value to pass to the process.
63 *
64 * @param input
65 * a <code>String</code>
66 */
67 public void setInput(String input) {
68 this.input = input;
69 }
70
71 /***
72 * Starts the process on bexee.
73 */
74 public void execute() throws BuildException {
75
76
77 if (url == null || operation == null || input == null) {
78 throw new BuildException("All of url, operation and value required");
79 }
80
81 Service service = new Service();
82 Call call = null;
83 try {
84 call = (Call) service.createCall();
85 call.setTargetEndpointAddress(url);
86 call.setOperation(operation);
87 call.addParameter("x", XMLType.XSD_STRING, ParameterMode.IN);
88 call.setReturnType(XMLType.XSD_STRING);
89 } catch (ServiceException e) {
90 throw new BuildException("Unable to create call", e);
91 }
92
93 try {
94 String result = (String) call.invoke(new Object[] { input });
95 log(result);
96 } catch (RemoteException e) {
97 throw new BuildException("Unable to invoke service", e);
98 }
99 }
100 }