scheu 2002/06/21 15:25:38 Modified: java/src/org/apache/axis/wsdl/fromJava Emitter.java java/test/wsdl Java2WsdlAntTask.java Wsdl2javaTestSuite.xml Log: Fix for Bugzilla defect http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10139 Fix was easier than expected. The initialization of serviceDesc and serviceDesc2 are moved inside the init() method so that they are setup for the "split wsdl" feature of Java2WSDL. Added a call to Java2WSDL to verify the "split wsdl" feature (roundtrip test). The generated interface and implementation wsdl files are not used in the test, but generating these wsdl files verifies that Java2WSDL does not abend. Revision Changes Path 1.44 +32 -30 xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java Index: Emitter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- Emitter.java 20 Jun 2002 20:35:47 -0000 1.43 +++ Emitter.java 21 Jun 2002 22:25:38 -0000 1.44 @@ -209,36 +209,6 @@ * @throws Exception */ public Document emit(int mode) throws Exception { - if (serviceDesc == null) { - serviceDesc = new ServiceDesc(); - serviceDesc.setImplClass(cls); - //serviceDesc.setStyle(); - TypeMappingRegistry tmr = new TypeMappingRegistryImpl(); - serviceDesc.setTypeMapping((TypeMapping) - tmr.getDefaultTypeMapping()); - } - - serviceDesc.setStopClasses(stopClasses); - serviceDesc.setAllowedMethods(allowedMethods); - serviceDesc.setDisallowedMethods(disallowedMethods); - - // If the class passed in is a portType, - // there may be an implClass that is used to - // obtain the method parameter names. In this case, - // a serviceDesc2 is built to get the method parameter names. - if (implCls != null && - implCls != cls && - serviceDesc2 == null) { - serviceDesc2 = new ServiceDesc(); - serviceDesc2.setImplClass(implCls); - TypeMappingRegistry tmr = new TypeMappingRegistryImpl(); - serviceDesc2.setTypeMapping((TypeMapping) - tmr.getDefaultTypeMapping()); - serviceDesc2.setStopClasses(stopClasses); - serviceDesc2.setAllowedMethods(allowedMethods); - serviceDesc2.setDisallowedMethods(disallowedMethods); - } - Document doc = null; Definition def = null; switch (mode) { @@ -392,6 +362,38 @@ * @throws Exception */ private void init() throws Exception { + + // Set up a ServiceDesc to use to introspect the Service + if (serviceDesc == null) { + serviceDesc = new ServiceDesc(); + serviceDesc.setImplClass(cls); + //serviceDesc.setStyle(); + TypeMappingRegistry tmr = new TypeMappingRegistryImpl(); + serviceDesc.setTypeMapping((TypeMapping) + tmr.getDefaultTypeMapping()); + } + + serviceDesc.setStopClasses(stopClasses); + serviceDesc.setAllowedMethods(allowedMethods); + serviceDesc.setDisallowedMethods(disallowedMethods); + + // If the class passed in is a portType, + // there may be an implClass that is used to + // obtain the method parameter names. In this case, + // a serviceDesc2 is built to get the method parameter names. + if (implCls != null && + implCls != cls && + serviceDesc2 == null) { + serviceDesc2 = new ServiceDesc(); + serviceDesc2.setImplClass(implCls); + TypeMappingRegistry tmr = new TypeMappingRegistryImpl(); + serviceDesc2.setTypeMapping((TypeMapping) + tmr.getDefaultTypeMapping()); + serviceDesc2.setStopClasses(stopClasses); + serviceDesc2.setAllowedMethods(allowedMethods); + serviceDesc2.setDisallowedMethods(disallowedMethods); + } + if (encodingList == null) { clsName = cls.getName(); clsName = clsName.substring(clsName.lastIndexOf('.') + 1); 1.14 +30 -1 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Java2WsdlAntTask.java 14 Jun 2002 22:39:50 -0000 1.13 +++ Java2WsdlAntTask.java 21 Jun 2002 22:25:38 -0000 1.14 @@ -73,9 +73,12 @@ public class Java2WsdlAntTask extends Task { private String namespace = ""; + private String namespaceImpl = null; private HashMap namespaceMap = new HashMap(); private String location = ""; + private String locationImport = null; private String output = "." ; + private String outputImpl = null; private String className = "." ; private String servicePortName = null ; private String portTypeName = null ; @@ -101,6 +104,9 @@ log("\tstopClasses:" + stopClasses, Project.MSG_VERBOSE); log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE); log("\tstyle:" + style, Project.MSG_VERBOSE); + log("\toutputImpl:" + outputImpl, Project.MSG_VERBOSE); + log("\tnamespaceImpl:" + namespaceImpl, Project.MSG_VERBOSE); + log("\tlocationImport:" + locationImport, Project.MSG_VERBOSE); // Instantiate the emitter Emitter emitter = new Emitter(); @@ -134,9 +140,17 @@ } } emitter.setIntfNamespace(namespace); + emitter.setImplNamespace(namespaceImpl); emitter.setLocationUrl(location); + emitter.setImportUrl(locationImport); emitter.setUseInheritedMethods(useInheritedMethods); - emitter.emit(output, Emitter.MODE_ALL); + if (outputImpl == null) { + // Normal case + emitter.emit(output, Emitter.MODE_ALL); + } else { + // Emit interface and implementation wsdls + emitter.emit(output, outputImpl); + } } catch (Throwable t) { StringWriter writer = new StringWriter(); t.printStackTrace(new PrintWriter(writer)); @@ -150,11 +164,21 @@ this.output = parameter; } + // The setter for the "outputImpl" attribute + public void setOutputImpl(String parameter) { + this.outputImpl = parameter; + } + // The setter for the "location" attribute public void setLocation(String parameter) { this.location = parameter; } + // The setter for the "locationImport" attribute + public void setLocationImport(String parameter) { + this.locationImport = parameter; + } + // The setter for the "className" attribute public void setClassName(String parameter) { this.className = parameter; @@ -178,6 +202,11 @@ // The setter for the "namespace" attribute public void setNamespace(String parameter) { this.namespace = parameter; + } + + // The setter for the "namespaceImpl" attribute + public void setNamespaceImpl(String parameter) { + this.namespaceImpl = parameter; } // The setter for the "useInheritedMethods" attribute 1.107 +16 -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.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- Wsdl2javaTestSuite.xml 21 Jun 2002 14:48:38 -0000 1.106 +++ Wsdl2javaTestSuite.xml 21 Jun 2002 22:25:38 -0000 1.107 @@ -193,7 +193,22 @@ <exclude name="test/wsdl/roundtrip/*TestCase.java" /> <exclude name="test/wsdl/roundtrip/*Impl.java" /> </javac> - <!-- Now create the WSDL file --> + + <!-- The following invocation of java2wsdl simply tests whether the + split wsdl function works. The generated wsdl files are not used. --> + + <java2wsdl output="build/work/test/wsdl/roundtrip/RoundtripIntf.wsdl" + outputImpl="build/work/test/wsdl/roundtrip/RoundtripImpl.wsdl" + className= "test.wsdl.roundtrip.RoundtripPortType" + useInheritedMethods="false" + namespace="http://roundtrip.wsdl.test" + namespaceImpl="http://roundtrip.wsdl.test" + location="http://localhost:8080/axis/services/RoundtripTest" + locationImport="file://build/work/test/wsdl/roundtrip/RoundtripIntf.wsdl"> + <mapping namespace="http://roundtrip.wsdl.test" package="test.wsdl.roundtrip"/> + </java2wsdl> + + <!-- Now create the real WSDL file --> <java2wsdl output="build/work/test/wsdl/roundtrip/Roundtrip.wsdl" className= "test.wsdl.roundtrip.RoundtripPortType" useInheritedMethods="false"