Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 74040 invoked by uid 500); 14 Jun 2002 22:39:51 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 74031 invoked by uid 500); 14 Jun 2002 22:39:51 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 14 Jun 2002 22:39:50 -0000 Message-ID: <20020614223950.78605.qmail@icarus.apache.org> From: scheu@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/test/wsdl/addrNoImplSEI AddressBookNoImplSEISoapBindingImpl.java AddressBook.wsdl Main.java AddressBookSOAPBindingImpl.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N scheu 2002/06/14 15:39:50 Modified: java/src/org/apache/axis/description ServiceDesc.java java/src/org/apache/axis/encoding/ser BeanDeserializer.java java/test/wsdl Java2WsdlAntTask.java Wsdl2javaTestSuite.xml java/test/wsdl/addrNoImplSEI AddressBook.wsdl Main.java Added: java/test/wsdl/addrNoImplSEI AddressBookNoImplSEISoapBindingImpl.java Removed: java/test/wsdl/addrNoImplSEI AddressBookSOAPBindingImpl.java Log: Problem: The class passed to Java2WSDL may contain methods that throw exceptions that are not allowed in an SEI. The operations in the SEI must throw RemoteException plus application specific exceptions. General exceptions (like java.lang.Exception or java.lang.NullPointerException) are not allowed in the SEI. Solution: Changed the ServiceDesc code that creates the FaultDesc objects. A FaultDesc is not created for exceptions in the 'java' or 'javax' packages. (Simple Change) I recently added an addrNoImplSEI testcase which tests proper processing if the server-side impl does not implement the SEI. (This test is meant to somewhat simulate a server-side EJB). I enhanced this testcase to roundtrip Java2WSDL and WSDL2Java. I added some general purpose throw clauses to the Impl class to make sure tht Java2WSDL properly ignored the exceptions when generating the SEI. Revision Changes Path 1.27 +11 -6 xml-axis/java/src/org/apache/axis/description/ServiceDesc.java Index: ServiceDesc.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- ServiceDesc.java 11 Jun 2002 14:53:54 -0000 1.26 +++ ServiceDesc.java 14 Jun 2002 22:39:50 -0000 1.27 @@ -740,7 +740,12 @@ for (int i=0; i < exceptionTypes.length; i++) { // Every remote method declares a java.rmi.RemoteException - if (exceptionTypes[i] != java.rmi.RemoteException.class) { + // Only interested in application specific exceptions. + // Ignore java and javax package exceptions. + Class ex = exceptionTypes[i]; + if (ex != java.rmi.RemoteException.class && + !ex.getName().startsWith("java.") && + !ex.getName().startsWith("javax.")) { // For JSR 101 v.1.0, there is a simple fault mapping // and a complexType fault mapping...both mappings @@ -756,7 +761,7 @@ /* Old Simple Type Mode - Field[] f = exceptionTypes[i].getDeclaredFields(); + Field[] f = ex.getDeclaredFields(); ArrayList exceptionParams = new ArrayList(); for (int j = 0; j < f.length; j++) { int mod = f[j].getModifiers(); @@ -771,7 +776,7 @@ exceptionParams.add(param); } } - String pkgAndClsName = exceptionTypes[i].getName(); + String pkgAndClsName = ex.getName(); FaultDesc fault = new FaultDesc(); fault.setName(pkgAndClsName); fault.setParameters(exceptionParams); @@ -783,12 +788,12 @@ ParameterDesc param = new ParameterDesc( new QName("", "fault"), ParameterDesc.IN, - tm.getTypeQName(exceptionTypes[i])); - param.setJavaType(exceptionTypes[i]); + tm.getTypeQName(ex)); + param.setJavaType(ex); ArrayList exceptionParams = new ArrayList(); exceptionParams.add(param); - String pkgAndClsName = exceptionTypes[i].getName(); + String pkgAndClsName = ex.getName(); FaultDesc fault = new FaultDesc(); fault.setName(pkgAndClsName); fault.setParameters(exceptionParams); 1.32 +3 -3 xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java Index: BeanDeserializer.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- BeanDeserializer.java 11 Jun 2002 14:53:55 -0000 1.31 +++ BeanDeserializer.java 14 Jun 2002 22:39:50 -0000 1.32 @@ -301,15 +301,15 @@ // Success! Register the target and deserializer. collectionIndex = -1; dSer.registerValueTarget( - new BeanPropertyTarget(value, propDesc)); + new BeanPropertyTarget(value, propDesc)); } else { // Success! This is a collection of properties so use the index collectionIndex++; dSer.registerValueTarget( - new BeanPropertyTarget(value, + new BeanPropertyTarget(value, propDesc, collectionIndex)); - } + } } return (SOAPHandler)dSer; } 1.13 +8 -0 xml-axis/java/test/wsdl/Java2WsdlAntTask.java Index: Java2WsdlAntTask.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/Java2WsdlAntTask.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Java2WsdlAntTask.java 31 May 2002 20:29:51 -0000 1.12 +++ Java2WsdlAntTask.java 14 Jun 2002 22:39:50 -0000 1.13 @@ -78,6 +78,7 @@ private String output = "." ; private String className = "." ; private String servicePortName = null ; + private String portTypeName = null ; private String implClass = null; private boolean useInheritedMethods = false; private String exclude = null; @@ -109,6 +110,8 @@ } if (servicePortName != null) emitter.setServicePortName(servicePortName); + if (portTypeName != null) + emitter.setPortTypeName(portTypeName); log("Java2WSDL " + className, Project.MSG_INFO); emitter.setCls(className); if (implClass != null) @@ -165,6 +168,11 @@ // The setter for the "servicePortName" attribute public void setServicePortName(String parameter) { this.servicePortName = parameter; + } + + // The setter for the "portTypeName" attribute + public void setPortTypeName(String parameter) { + this.portTypeName = parameter; } // The setter for the "namespace" attribute 1.104 +57 -1 xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml Index: Wsdl2javaTestSuite.xml =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- Wsdl2javaTestSuite.xml 12 Jun 2002 18:41:12 -0000 1.103 +++ Wsdl2javaTestSuite.xml 14 Jun 2002 22:39:50 -0000 1.104 @@ -73,7 +73,19 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.2 +4 -4 xml-axis/java/test/wsdl/addrNoImplSEI/AddressBook.wsdl Index: AddressBook.wsdl =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/addrNoImplSEI/AddressBook.wsdl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AddressBook.wsdl 21 May 2002 17:15:50 -0000 1.1 +++ AddressBook.wsdl 14 Jun 2002 22:39:50 -0000 1.2 @@ -57,7 +57,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -100,8 +100,8 @@ - - + + 1.2 +18 -5 xml-axis/java/test/wsdl/addrNoImplSEI/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/addrNoImplSEI/Main.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Main.java 21 May 2002 17:15:50 -0000 1.1 +++ Main.java 14 Jun 2002 22:39:50 -0000 1.2 @@ -106,7 +106,7 @@ ph.getExchange() + "-" + ph.getNumber()); } - private static Object doit (AddressBook ab) throws Exception { + private static Object doit (AddressBookNoImplSEI ab) throws Exception { System.err.println (">> Storing address for '" + name1 + "'"); ab.addEntry (name1, addr1); System.err.println (">> Querying address for '" + name1 + "'"); @@ -121,6 +121,19 @@ resp = ab.getAddressFromName (name1); System.err.println (">> Response is:"); printAddress (resp); + + // Test NPE + try { + ab.addEntry(null, null); + throw new Exception("Expected exception when calling addEntry with null params"); + } catch (java.rmi.RemoteException e) { + if (e.detail instanceof java.lang.IllegalArgumentException) { + // Good! Expected this! + } else { + throw e; // This is not right! + } + } + return resp; } @@ -131,11 +144,11 @@ System.err.println ("Using proxy without session maintenance."); System.err.println ("(queries without session should say: \"ADDRESS NOT FOUND!\")"); - AddressBookService abs = new AddressBookServiceLocator(); + AddressBookNoImplSEIService abs = new AddressBookNoImplSEIServiceLocator(); opts.setDefaultURL( abs.getAddressBookNoImplSEIAddress() ); URL serviceURL = new URL(opts.getURL()); - AddressBook ab1 = null; + AddressBookNoImplSEI ab1 = null; if (serviceURL == null) { ab1 = abs.getAddressBookNoImplSEI(); } @@ -148,14 +161,14 @@ } System.err.println ("\n\nUsing proxy with session maintenance."); - AddressBook ab2 = null; + AddressBookNoImplSEI ab2 = null; if (serviceURL == null) { ab2 = abs.getAddressBookNoImplSEI(); } else { ab2 = abs.getAddressBookNoImplSEI(serviceURL); } - ((AddressBookSOAPBindingStub) ab2).setMaintainSession (true); + ((AddressBookNoImplSEISoapBindingStub) ab2).setMaintainSession (true); ret = doit (ab2); if (ret == null) { throw new Exception("session test expected non-null response, got "+ret); 1.1 xml-axis/java/test/wsdl/addrNoImplSEI/AddressBookNoImplSEISoapBindingImpl.java Index: AddressBookNoImplSEISoapBindingImpl.java =================================================================== /** * AddressBookNoImplSEISOAPBindingImpl.java * * This file was hand modified from the Emmitter generated code. */ package test.wsdl.addrNoImplSEI; import java.util.Hashtable; import java.util.Map; // Don't implement the AddressBook interface public class AddressBookNoImplSEISoapBindingImpl { private Map addresses = new Hashtable(); public void addEntry(java.lang.String name, test.wsdl.addrNoImplSEI.Address address) throws java.rmi.RemoteException, java.lang.IllegalArgumentException // This should be accepted { if (address == null) { throw new java.lang.IllegalArgumentException(); } this.addresses.put(name, address); } public test.wsdl.addrNoImplSEI.Address getAddressFromName(java.lang.String name) throws java.rmi.RemoteException, javax.xml.rpc.JAXRPCException // This should be accepted { return (test.wsdl.addrNoImplSEI.Address) this.addresses.get(name); } }