1 package samples.faults; 2 3 import org.apache.axis.encoding.ser.BeanSerializerFactory; 4 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 5 import org.apache.axis.AxisFault; 6 import org.apache.axis.utils.Options; 7 import org.apache.axis.transport.http.SimpleAxisWorker; 8 import org.apache.axis.description.OperationDesc; 9 10 import javax.xml.rpc.ServiceFactory ; 11 import javax.xml.rpc.Service ; 12 import javax.xml.rpc.Call ; 13 import javax.xml.rpc.encoding.TypeMappingRegistry ; 14 import javax.xml.rpc.encoding.TypeMapping ; 15 import javax.xml.namespace.QName ; 16 import java.net.URL ; 17 import java.util.Map ; 18 import java.util.Iterator ; 19 20 import samples.faults.Employee; 21 22 public class EmployeeClient { 23 public static void main(String [] args) throws Exception { 24 Options opts = new Options(args); 25 String uri = "http://faults.samples"; 26 String serviceName = "EmployeeInfoService"; 27 ServiceFactory serviceFactory = ServiceFactory.newInstance(); 28 Service service = serviceFactory.createService(new QName (uri, serviceName)); 29 30 TypeMappingRegistry registry = service.getTypeMappingRegistry(); 31 TypeMapping map = registry.getDefaultTypeMapping(); 32 33 QName employeeQName = new QName ("http://faults.samples", "Employee"); 34 map.register(Employee.class, employeeQName, new BeanSerializerFactory(Employee.class, employeeQName), new BeanDeserializerFactory(Employee.class, employeeQName)); 35 36 QName faultQName = new QName ("http://faults.samples", "NoSuchEmployeeFault"); 37 map.register(NoSuchEmployeeFault.class, faultQName, new BeanSerializerFactory(NoSuchEmployeeFault.class, faultQName), new BeanDeserializerFactory(NoSuchEmployeeFault.class, faultQName)); 38 39 Call call = service.createCall(); 40 call.setTargetEndpointAddress(new URL (opts.getURL()).toString()); 41 call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); 42 call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE); 43 call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://faults.samples"); 44 call.setOperationName( new QName (uri, "getEmployee") ); 45 46 String [] args2 = opts.getRemainingArgs(); 47 System.out.println("Trying :" + args2[0]); 48 Employee emp = (Employee) call.invoke(new Object []{ args2[0] }); 49 System.out.println("Got :" + emp.getEmployeeID()); 50 } 51 } 52 | Popular Tags |