1 16 17 package samples.bidbuy ; 18 19 import org.apache.axis.client.Call; 20 import org.apache.axis.client.Service; 21 import org.apache.axis.encoding.XMLType; 22 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 23 import org.apache.axis.encoding.ser.BeanSerializerFactory; 24 import org.apache.axis.utils.Options; 25 26 import javax.xml.namespace.QName ; 27 import javax.xml.rpc.ParameterMode ; 28 import java.net.URL ; 29 import java.util.Calendar ; 30 31 32 38 public class TestClient { 39 40 private static Service service = null ; 41 private static Call call = null; 42 43 49 private static void test(String method, Object toSend) { 50 51 } 52 53 60 public static void main(String args[]) throws Exception { 61 Options opts = new Options(args); 63 service = new Service(); 64 call = (Call) service.createCall(); 65 call.setTargetEndpointAddress( new URL (opts.getURL()) ); 66 call.setUseSOAPAction(true); 67 call.setSOAPActionURI("http://www.soapinterop.org/Bid"); 68 69 QName poqn = new QName ("http://www.soapinterop.org/Bid", 71 "PurchaseOrder"); 72 Class cls = PurchaseOrder.class; 73 call.registerTypeMapping(cls, poqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); 74 75 QName aqn = new QName ("http://www.soapinterop.org/Bid", "Address"); 77 cls = Address.class; 78 call.registerTypeMapping(cls, aqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); 79 80 QName liqn = new QName ("http://www.soapinterop.org/Bid", "LineItem"); 82 cls = LineItem.class; 83 call.registerTypeMapping(cls, liqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); 84 85 try { 86 call.setOperationName( new QName ("http://www.soapinterop.org/Bid", "Buy" )); 88 call.addParameter( "PO", poqn, ParameterMode.IN ); 89 call.setReturnType( XMLType.XSD_STRING ); 90 91 LineItem[] li = new LineItem[2]; 92 li[0] = new LineItem("Tricorder", 1, "2500.95"); 93 li[1] = new LineItem("Phasor", 3, "7250.95"); 94 95 PurchaseOrder po = new PurchaseOrder( 96 "NCC-1701", 97 Calendar.getInstance(), 98 new Address("Sam Ruby", "Home", "Raleigh", "NC", "27676"), 99 new Address("Lou Gerstner", "Work", "Armonk", "NY", "15222"), 100 li 101 ); 102 103 String receipt = (String ) call.invoke( new Object [] {po} ); 105 106 System.out.println(receipt); 107 } catch (Exception e) { 108 System.out.println("Buy failed: " + e); 109 throw e; 110 } 111 } 112 113 } 114 | Popular Tags |