1 16 17 package test.wsdl.addrNoImplSEI; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.transport.http.SimpleAxisWorker; 21 import org.apache.axis.utils.NetworkUtils; 22 23 import javax.xml.namespace.QName ; 24 import javax.xml.rpc.Service ; 25 import javax.xml.rpc.ServiceFactory ; 26 import javax.xml.rpc.Stub ; 27 import javax.xml.rpc.encoding.TypeMapping ; 28 import javax.xml.rpc.encoding.TypeMappingRegistry ; 29 import java.net.URL ; 30 31 32 35 public class AddressBookDynamicProxyTestCase extends TestCase { 36 37 public AddressBookDynamicProxyTestCase(String name) { 38 super(name); 39 } 40 41 public void testAddressBookServiceUsingDynamicProxy() throws Exception { 43 String nameSpaceUri = "http://addrNoImplSEI.wsdl.test"; 44 String serviceName = "AddressBookNoImplSEIService"; 45 46 String thisHost = NetworkUtils.getLocalHostname(); 47 String thisPort = System.getProperty("test.functional.ServicePort", "8080"); 48 49 String wsdlLocation = "http://" + thisHost + ":" + thisPort + "/axis/services/AddressBookNoImplSEI?WSDL"; 51 URL orgWsdlUrl = new URL (wsdlLocation); 52 53 ServiceFactory serviceFactory = ServiceFactory.newInstance(); 54 Service addressBookService = 55 serviceFactory.createService(orgWsdlUrl, 56 new QName (nameSpaceUri, serviceName)); 57 58 TypeMappingRegistry registry = addressBookService.getTypeMappingRegistry(); 60 TypeMapping map = registry.getDefaultTypeMapping(); 61 map.register(test.wsdl.addrNoImplSEI.Address.class, 62 new QName ("urn:AddrNoImplSEI", "Address"), 63 new org.apache.axis.encoding.ser.BeanSerializerFactory(test.wsdl.addrNoImplSEI.Address.class, new QName ("urn:AddrNoImplSEI", "Address")), 64 new org.apache.axis.encoding.ser.BeanDeserializerFactory(test.wsdl.addrNoImplSEI.Address.class, new QName ("urn:AddrNoImplSEI", "Address"))); 65 map.register(test.wsdl.addrNoImplSEI._Phone.class, 66 new QName ("urn:AddrNoImplSEI", "_Phone"), 67 new org.apache.axis.encoding.ser.BeanSerializerFactory(test.wsdl.addrNoImplSEI._Phone.class, new QName ("urn:AddrNoImplSEI", "_Phone")), 68 new org.apache.axis.encoding.ser.BeanDeserializerFactory(test.wsdl.addrNoImplSEI._Phone.class, new QName ("urn:AddrNoImplSEI", "_Phone"))); 69 map.register(test.wsdl.addrNoImplSEI.StateType.class, 70 new QName ("urn:AddrNoImplSEI", "StateType"), 71 new org.apache.axis.encoding.ser.EnumSerializerFactory(test.wsdl.addrNoImplSEI.StateType.class, new QName ("urn:AddrNoImplSEI", "StateType")), 72 new org.apache.axis.encoding.ser.EnumDeserializerFactory(test.wsdl.addrNoImplSEI.StateType.class, new QName ("urn:AddrNoImplSEI", "StateType"))); 73 74 AddressBookNoImplSEI myProxy = (AddressBookNoImplSEI) addressBookService.getPort(AddressBookNoImplSEI.class); 75 76 ((Stub ) myProxy)._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); 78 79 String name1; 80 Address addr1; 81 _Phone phone1; 82 83 name1 = "Purdue Boilermaker"; 84 addr1 = new Address(); 85 phone1 = new _Phone(); 86 addr1.setStreetNum(1); 87 addr1.setStreetName("University Drive"); 88 addr1.setCity("West Lafayette"); 89 addr1.setState(StateType.IN); 90 addr1.setZip(47907); 91 phone1.setAreaCode(765); 92 phone1.setExchange("494"); 93 phone1.setNumber("4900"); 94 addr1.setPhone(phone1); 95 96 myProxy.addEntry(name1, addr1); 98 99 test.wsdl.addrNoImplSEI.Address[] addresses = myProxy.getAddresses(); 101 assertTrue(addresses.length > 0); 102 } 103 } 104 105 106 | Popular Tags |