001: /*
002: * ====================================================================
003: *
004: * XFLOW - Process Management System
005: * Copyright (C) 2003 Rob Tan
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions, and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions, and the disclaimer that follows
017: * these conditions in the documentation and/or other materials
018: * provided with the distribution.
019: *
020: * 3. The name "XFlow" must not be used to endorse or promote products
021: * derived from this software without prior written permission. For
022: * written permission, please contact rcktan@yahoo.com
023: *
024: * 4. Products derived from this software may not be called "XFlow", nor
025: * may "XFlow" appear in their name, without prior written permission
026: * from the XFlow Project Management (rcktan@yahoo.com)
027: *
028: * In addition, we request (but do not require) that you include in the
029: * end-user documentation provided with the redistribution and/or in the
030: * software itself an acknowledgement equivalent to the following:
031: * "This product includes software developed by the
032: * XFlow Project (http://xflow.sourceforge.net/)."
033: * Alternatively, the acknowledgment may be graphical using the logos
034: * available at http://xflow.sourceforge.net/
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE XFLOW AUTHORS OR THE PROJECT
040: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: *
049: * ====================================================================
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the XFlow Project and was originally
052: * created by Rob Tan (rcktan@yahoo.com)
053: * For more information on the XFlow Project, please see:
054: * <http://xflow.sourceforge.net/>.
055: * ====================================================================
056: */
057:
058: package xflow.test;
059:
060: import org.apache.axis.client.Call;
061: import org.apache.axis.client.Service;
062: import org.apache.axis.encoding.XMLType;
063: import org.apache.axis.utils.Options;
064: import javax.xml.namespace.QName;
065: import javax.xml.rpc.ParameterMode;
066:
067: import xflow.common.*;
068: import xflow.security.*;
069:
070: public class SetGetVariableWS {
071: public static void main(String[] args) throws Exception {
072:
073: Options options = new Options(args);
074:
075: String endpoint = "http://localhost:8080/axis/services/XflowService";
076:
077: Service service = new Service();
078:
079: // Set Variable
080:
081: Call call = (Call) service.createCall();
082: QName qn = new QName("urn:XflowService", "WorkItemId");
083: call
084: .registerTypeMapping(
085: WorkItemId.class,
086: qn,
087: new org.apache.axis.encoding.ser.BeanSerializerFactory(
088: WorkItemId.class, qn),
089: new org.apache.axis.encoding.ser.BeanDeserializerFactory(
090: WorkItemId.class, qn));
091:
092: qn = new QName("urn:XflowService", "WorkflowId");
093: call
094: .registerTypeMapping(
095: WorkItemId.class,
096: qn,
097: new org.apache.axis.encoding.ser.BeanSerializerFactory(
098: WorkflowId.class, qn),
099: new org.apache.axis.encoding.ser.BeanDeserializerFactory(
100: WorkflowId.class, qn));
101:
102: QName qn1 = new QName("urn:XflowService", "WorkItem");
103: call
104: .registerTypeMapping(
105: WorkItem.class,
106: qn1,
107: new org.apache.axis.encoding.ser.BeanSerializerFactory(
108: WorkItem.class, qn1),
109: new org.apache.axis.encoding.ser.BeanDeserializerFactory(
110: WorkItem.class, qn1));
111:
112: QName qn2 = new QName("urn:XflowService", "User");
113: call
114: .registerTypeMapping(
115: User.class,
116: qn2,
117: new org.apache.axis.encoding.ser.BeanSerializerFactory(
118: User.class, qn2),
119: new org.apache.axis.encoding.ser.BeanDeserializerFactory(
120: User.class, qn2));
121:
122: call.setTargetEndpointAddress(new java.net.URL(endpoint));
123: call.setOperationName("setVariable");
124: call.addParameter("op1", XMLType.XSD_INT, ParameterMode.IN);
125: call.addParameter("op2", XMLType.XSD_STRING, ParameterMode.IN);
126: call.addParameter("op3", XMLType.XSD_STRING, ParameterMode.IN);
127: call.addParameter("op4", qn2, ParameterMode.IN);
128: Integer wfId = new Integer(args[0]);
129: String varName = args[1];
130: String varVal = args[2];
131: User user = new User("rtan", "rtan");
132:
133: call.invoke(new Object[] { wfId, varName, varVal, user });
134:
135: // Get Variable
136:
137: call = (Call) service.createCall();
138: call
139: .registerTypeMapping(
140: User.class,
141: qn2,
142: new org.apache.axis.encoding.ser.BeanSerializerFactory(
143: User.class, qn2),
144: new org.apache.axis.encoding.ser.BeanDeserializerFactory(
145: User.class, qn2));
146:
147: call.setTargetEndpointAddress(new java.net.URL(endpoint));
148: call.setOperationName("getVariable");
149: call.addParameter("op1", XMLType.XSD_INT, ParameterMode.IN);
150: call.addParameter("op2", XMLType.XSD_STRING, ParameterMode.IN);
151: call.addParameter("op3", qn2, ParameterMode.IN);
152: call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
153:
154: String result = (String) call.invoke(new Object[] { wfId,
155: varName, user });
156: System.out.println("Result: " + result);
157: }
158: }
|