01: package samples.faults;
02:
03: import org.apache.axis.encoding.ser.BeanSerializerFactory;
04: import org.apache.axis.encoding.ser.BeanDeserializerFactory;
05: import org.apache.axis.AxisFault;
06: import org.apache.axis.utils.Options;
07: import org.apache.axis.transport.http.SimpleAxisWorker;
08: import org.apache.axis.description.OperationDesc;
09:
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,
29: serviceName));
30:
31: TypeMappingRegistry registry = service.getTypeMappingRegistry();
32: TypeMapping map = registry.getDefaultTypeMapping();
33:
34: QName employeeQName = new QName("http://faults.samples",
35: "Employee");
36: map
37: .register(Employee.class, employeeQName,
38: new BeanSerializerFactory(Employee.class,
39: employeeQName),
40: new BeanDeserializerFactory(Employee.class,
41: employeeQName));
42:
43: QName faultQName = new QName("http://faults.samples",
44: "NoSuchEmployeeFault");
45: map.register(NoSuchEmployeeFault.class, faultQName,
46: new BeanSerializerFactory(NoSuchEmployeeFault.class,
47: faultQName), new BeanDeserializerFactory(
48: NoSuchEmployeeFault.class, faultQName));
49:
50: Call call = service.createCall();
51: call
52: .setTargetEndpointAddress(new URL(opts.getURL())
53: .toString());
54: call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
55: call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
56: call.setProperty(Call.SOAPACTION_URI_PROPERTY,
57: "http://faults.samples");
58: call.setOperationName(new QName(uri, "getEmployee"));
59:
60: String[] args2 = opts.getRemainingArgs();
61: System.out.println("Trying :" + args2[0]);
62: Employee emp = (Employee) call
63: .invoke(new Object[] { args2[0] });
64: System.out.println("Got :" + emp.getEmployeeID());
65: }
66: }
|