Debian Codegraph @

samples/userguide/example5/Client.java

raw
1 /*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 {
29 public static void main(String [] args) throws Exception
30 {
31 Options options = new Options(args);
32
33 Order order = new Order();
34 order.setCustomerName("Glen Daniels");
35 order.setShippingAddress("275 Grove Street, Newton, MA");
36
37 String [] items = new String[] { "mp3jukebox", "1600mahBattery" };
38 int [] quantities = new int [] { 1, 4 };
39
40 order.setItemCodes(items);
41 order.setQuantities(quantities);
42
43 Service service = new Service();
44 Call call = (Call) service.createCall();
45 QName qn = new QName( "urn:BeanService", "Order" );
46
47 call.registerTypeMapping(Order.class, qn,
48 new org.apache.axis.encoding.ser.BeanSerializerFactory(Order.class, qn),
49 new org.apache.axis.encoding.ser.BeanDeserializerFactory(Order.class, qn));
50 String result;
51 try {
52 call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
53 call.setOperationName( new QName("OrderProcessor", "processOrder") );
54 call.addParameter( "arg1", qn, ParameterMode.IN );
55 call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );
56
57 result = (String) call.invoke( new Object[] { order } );
58 } catch (AxisFault fault) {
59 result = "Error : " + fault.toString();
60 }
61
62 System.out.println(result);
63 }
64 }