01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package samples.userguide.example5;
18:
19: import org.apache.axis.AxisFault;
20: import org.apache.axis.client.Call;
21: import org.apache.axis.client.Service;
22: import org.apache.axis.utils.Options;
23:
24: import javax.xml.namespace.QName;
25: import javax.xml.rpc.ParameterMode;
26:
27: public class Client {
28: public static void main(String[] args) throws Exception {
29: Options options = new Options(args);
30:
31: Order order = new Order();
32: order.setCustomerName("Glen Daniels");
33: order.setShippingAddress("275 Grove Street, Newton, MA");
34:
35: String[] items = new String[] { "mp3jukebox", "1600mahBattery" };
36: int[] quantities = new int[] { 1, 4 };
37:
38: order.setItemCodes(items);
39: order.setQuantities(quantities);
40:
41: Service service = new Service();
42: Call call = (Call) service.createCall();
43: QName qn = new QName("urn:BeanService", "Order");
44:
45: call
46: .registerTypeMapping(
47: Order.class,
48: qn,
49: new org.apache.axis.encoding.ser.BeanSerializerFactory(
50: Order.class, qn),
51: new org.apache.axis.encoding.ser.BeanDeserializerFactory(
52: Order.class, qn));
53: String result;
54: try {
55: call.setTargetEndpointAddress(new java.net.URL(options
56: .getURL()));
57: call.setOperationName(new QName("OrderProcessor",
58: "processOrder"));
59: call.addParameter("arg1", qn, ParameterMode.IN);
60: call
61: .setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
62:
63: result = (String) call.invoke(new Object[] { order });
64: } catch (AxisFault fault) {
65: result = "Error : " + fault.toString();
66: }
67:
68: System.out.println(result);
69: }
70: }
|