1 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 } 65 | Popular Tags |