scheu 02/02/20 09:17:36 Modified: java/src/org/apache/axis/utils resources.properties java/src/org/apache/axis/wsdl Java2WSDL.java WSDL2Java.java java/src/org/apache/axis/wsdl/toJava Emitter.java JavaWriterFactory.java WriterFactory.java java/test/wsdl Java2WsdlAntTask.java Wsdl2javaAntTask.java Wsdl2javaTestSuite.xml Added: java/src/org/apache/axis/wsdl/toJava NoopWriterFactory.java Log: The command line invocations of Java2WSDL and WSDL2Java use the DefaultSOAP12TypeMappingImpl. This is necessary to produce SOAP 1.2 JAX-RPC compliant wsld and bindings. When ?wsdl is invoked, the default type mapping for the service is used. Changes were made to allow the command line invocations of Java2WSDL and WSDL2Java to use the 1.1 version of the mappings. (Russell believes that this is necessary to do the interop round 3 tests.) The new option for both emitters is -typeMappingVersion or -T. The valid arguments are 1.1 and 1.2. The default is 1.2. Also changed the ant emitter tasks to accept typeMappingVersion. Revision Changes Path 1.56 +4 -0 xml-axis/java/src/org/apache/axis/utils/resources.properties Index: resources.properties =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- resources.properties 19 Feb 2002 20:55:00 -0000 1.55 +++ resources.properties 20 Feb 2002 17:17:35 -0000 1.56 @@ -646,3 +646,7 @@ AttrNotSimpleType00=Attribute {0} is of type {1}, which is not a simple type +optionTypeMapping00=indicate 1.1 or 1.2. The default is 1.2 (SOAP 1.2 JAX-RPC compliant) +badTypeMappingOption00=The -typeMappingVersion argument must be 1.1 or 1.2 +j2wopttypeMapping00=indicate 1.1 or 1.2. The default is 1.2 (SOAP 1.2 JAX-RPC compliant) +j2wBadTypeMapping00=The -typeMappingVersion argument must be 1.1 or 1.2 1.9 +28 -2 xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java Index: Java2WSDL.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Java2WSDL.java 18 Feb 2002 17:11:49 -0000 1.8 +++ Java2WSDL.java 20 Feb 2002 17:17:36 -0000 1.9 @@ -62,6 +62,9 @@ import org.apache.axis.wsdl.fromJava.Emitter; import org.apache.axis.utils.JavaUtils; +import org.apache.axis.encoding.DefaultTypeMappingImpl; +import org.apache.axis.encoding.DefaultSOAP12TypeMappingImpl; + import java.util.HashMap; import java.util.List; @@ -92,6 +95,7 @@ protected static final int IMPL_CLASS_OPT = 'i'; protected static final int METHODS_NOTALLOWED_OPT = 'x'; protected static final int STOP_CLASSES_OPT = 'c'; + protected static final int TYPEMAPPING_OPT = 'T'; /** * Define the understood options. Each CLOptionDescriptor contains: @@ -170,11 +174,15 @@ new CLOptionDescriptor("exclude", CLOptionDescriptor.ARGUMENT_REQUIRED, METHODS_NOTALLOWED_OPT, - JavaUtils.getMessage("j2woptexclude00")), + JavaUtils.getMessage("j2woptexclude00")), new CLOptionDescriptor("stopClasses", CLOptionDescriptor.ARGUMENT_REQUIRED, STOP_CLASSES_OPT, - JavaUtils.getMessage("j2woptstopClass00")) + JavaUtils.getMessage("j2woptstopClass00")), + new CLOptionDescriptor("typeMappingVersion", + CLOptionDescriptor.ARGUMENT_REQUIRED, + TYPEMAPPING_OPT, + JavaUtils.getMessage("j2wopttypeMapping00")) }; @@ -301,6 +309,19 @@ case STOP_CLASSES_OPT: emitter.setStopClasses(option.getArgument()); break; + + case TYPEMAPPING_OPT: + String value = option.getArgument(); + if (option.equals("1.1")) { + emitter.setDefaultTypeMapping( + DefaultTypeMappingImpl.create()); + } else if (option.equals("1.2")) { + emitter.setDefaultTypeMapping( + DefaultSOAP12TypeMappingImpl.create()); + } else { + System.out.println(JavaUtils.getMessage("j2wBadTypeMapping00")); + } + break; } } @@ -316,6 +337,11 @@ printUsage(); } + // Default to SOAP 1.2 JAX-RPC mapping + if (emitter.getDefaultTypeMapping() == null) { + emitter.setDefaultTypeMapping(DefaultSOAP12TypeMappingImpl.create()); + } + if (!namespaceMap.isEmpty()) { emitter.setNamespaceMap(namespaceMap); } 1.7 +63 -3 xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java Index: WSDL2Java.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WSDL2Java.java 6 Feb 2002 21:08:54 -0000 1.6 +++ WSDL2Java.java 20 Feb 2002 17:17:36 -0000 1.7 @@ -62,8 +62,14 @@ import org.apache.axis.utils.JavaUtils; import org.apache.axis.wsdl.toJava.Emitter; +import org.apache.axis.wsdl.toJava.BaseTypeMapping; import org.apache.axis.wsdl.toJava.JavaWriterFactory; import org.apache.axis.wsdl.toJava.GeneratedFileInfo; +import org.apache.axis.encoding.DefaultTypeMappingImpl; +import org.apache.axis.encoding.DefaultSOAP12TypeMappingImpl; +import org.apache.axis.encoding.TypeMapping; + +import javax.wsdl.QName; import org.w3c.dom.Document; @@ -94,6 +100,7 @@ protected static final int PACKAGE_OPT = 'p'; protected static final int DEBUG_OPT = 'D'; protected static final int ALL_OPT = 'a'; + protected static final int TYPEMAPPING_OPT = 'T'; // Scope constants public static final byte NO_EXPLICIT_SCOPE = 0x00; @@ -104,6 +111,8 @@ // The emitter framework Emitter class. private Emitter emitter; + JavaWriterFactory writerFactory = null; + /** * Define the understood options. Each CLOptionDescriptor contains: * - The "long" version of the option. Eg, "help" means that "--help" will @@ -161,7 +170,11 @@ new CLOptionDescriptor("Debug", CLOptionDescriptor.ARGUMENT_DISALLOWED, DEBUG_OPT, - JavaUtils.getMessage("optionDebug00")) + JavaUtils.getMessage("optionDebug00")), + new CLOptionDescriptor("typeMappingVersion", + CLOptionDescriptor.ARGUMENT_REQUIRED, + TYPEMAPPING_OPT, + JavaUtils.getMessage("optionTypeMapping00")) }; /** @@ -169,7 +182,7 @@ */ public WSDL2Java() { // Instantiate the emitter - JavaWriterFactory writerFactory = new JavaWriterFactory(); + writerFactory = new JavaWriterFactory(); emitter = new Emitter(writerFactory); writerFactory.setEmitter(emitter); } // ctor @@ -389,6 +402,7 @@ String wsdlURI = null; HashMap namespaceMap = new HashMap(); boolean bPackageOpt = false; + String typeMappingVersion = "1.2"; // Parse the arguments CLArgsParser parser = new CLArgsParser(args, options); @@ -486,9 +500,19 @@ case DEBUG_OPT: wsdl2java.debug(true); break; + case TYPEMAPPING_OPT: + String tmValue = option.getArgument(); + if (tmValue.equals("1.1")) { + typeMappingVersion = "1.1"; + } else if (tmValue.equals("1.2")) { + typeMappingVersion = "1.2"; + } else { + System.out.println(JavaUtils.getMessage("badTypeMappingOption00")); + } + break; } } - + // validate argument combinations // if (wsdlURI == null) { @@ -503,6 +527,7 @@ wsdl2java.setNamespaceMap(namespaceMap); } + wsdl2java.setTypeMappingVersion(typeMappingVersion); wsdl2java.emit(wsdlURI); // everything is good @@ -514,6 +539,41 @@ } } + public void setTypeMappingVersion(String typeMappingVersion) { + if (typeMappingVersion.equals("1.1")) { + writerFactory.setBaseTypeMapping( + new BaseTypeMapping() { + final TypeMapping defaultTM = DefaultTypeMappingImpl.create(); + public String getBaseName(QName qNameIn) { + javax.xml.rpc.namespace.QName qName = + new javax.xml.rpc.namespace.QName( + qNameIn.getNamespaceURI(), + qNameIn.getLocalPart()); + Class cls = defaultTM.getClassForQName(qName); + if (cls == null) + return null; + else + return JavaUtils.getTextClassName(cls.getName()); + } + }); + } else { + writerFactory.setBaseTypeMapping( + new BaseTypeMapping() { + final TypeMapping defaultTM = DefaultSOAP12TypeMappingImpl.create(); + public String getBaseName(QName qNameIn) { + javax.xml.rpc.namespace.QName qName = + new javax.xml.rpc.namespace.QName( + qNameIn.getNamespaceURI(), + qNameIn.getLocalPart()); + Class cls = defaultTM.getClassForQName(qName); + if (cls == null) + return null; + else + return JavaUtils.getTextClassName(cls.getName()); + } + }); + } + } /** * Print usage message and exit */ 1.19 +0 -52 xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java Index: Emitter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- Emitter.java 13 Feb 2002 21:07:15 -0000 1.18 +++ Emitter.java 20 Feb 2002 17:17:36 -0000 1.19 @@ -585,57 +585,5 @@ } } // main - private static class NoopWriterFactory implements WriterFactory { - public void writerPass(Definition def, SymbolTable symbolTable) {} - public Writer getWriter(Message message, SymbolTable symbolTable) { - return new NoopWriter(); - } - public Writer getWriter(PortType portType, SymbolTable symbolTable) { - return new NoopWriter(); - } - - public Writer getWriter(Binding binding, SymbolTable symbolTable) { - return new NoopWriter(); - } - - public Writer getWriter(Service service, SymbolTable symbolTable) { - return new NoopWriter(); - } - - public Writer getWriter(TypeEntry type, SymbolTable symbolTable) { - return new NoopWriter(); - } - - public Writer getWriter(Definition definition, SymbolTable symbolTable) { - return new NoopWriter(); - } - - public void setEmitter(Emitter emitter) {} - - /** - * Get TypeMapping to use for translating - * QNames to java base types - */ - BaseTypeMapping btm = null; - public BaseTypeMapping getBaseTypeMapping() { - if (btm == null) { - btm = new BaseTypeMapping() { - TypeMapping defaultTM = DefaultSOAP12TypeMappingImpl.create(); - public String getBaseName(QName qNameIn) { - javax.xml.rpc.namespace.QName qName = - new javax.xml.rpc.namespace.QName( - qNameIn.getNamespaceURI(), - qNameIn.getLocalPart()); - Class cls = defaultTM.getClassForQName(qName); - if (cls == null) - return null; - else - return JavaUtils.getTextClassName(cls.getName()); - } - }; - } - return btm; - } - } } 1.15 +3 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriterFactory.java Index: JavaWriterFactory.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriterFactory.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- JavaWriterFactory.java 14 Feb 2002 14:59:31 -0000 1.14 +++ JavaWriterFactory.java 20 Feb 2002 17:17:36 -0000 1.15 @@ -521,6 +521,9 @@ * QNames to java base types */ BaseTypeMapping btm = null; + public void setBaseTypeMapping(BaseTypeMapping btm) { + this.btm = btm; + } public BaseTypeMapping getBaseTypeMapping() { if (btm == null) { btm = new BaseTypeMapping() { 1.4 +2 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/WriterFactory.java Index: WriterFactory.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/WriterFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- WriterFactory.java 8 Feb 2002 23:18:54 -0000 1.3 +++ WriterFactory.java 20 Feb 2002 17:17:36 -0000 1.4 @@ -121,5 +121,7 @@ * Get TypeMapping to use for translating * QNames to java base types */ + public void setBaseTypeMapping(BaseTypeMapping btm); public BaseTypeMapping getBaseTypeMapping(); + } 1.1 xml-axis/java/src/org/apache/axis/wsdl/toJava/NoopWriterFactory.java Index: NoopWriterFactory.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.axis.wsdl.toJava; import org.apache.axis.utils.JavaUtils; import org.w3c.dom.Document; import javax.wsdl.Binding; import javax.wsdl.Definition; import javax.wsdl.Message; import javax.wsdl.PortType; import javax.wsdl.Service; import javax.wsdl.WSDLException; import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; import java.util.Vector; import javax.wsdl.QName; import org.apache.axis.encoding.TypeMapping; import org.apache.axis.encoding.DefaultSOAP12TypeMappingImpl; /** * This is WSDL2Java's implementation of the NoopWriterFactor */ class NoopWriterFactory extends JavaWriterFactory { public void writerPass(Definition def, SymbolTable symbolTable) {} public Writer getWriter(Message message, SymbolTable symbolTable) { return new NoopWriter(); } public Writer getWriter(PortType portType, SymbolTable symbolTable) { return new NoopWriter(); } public Writer getWriter(Binding binding, SymbolTable symbolTable) { return new NoopWriter(); } public Writer getWriter(Service service, SymbolTable symbolTable) { return new NoopWriter(); } public Writer getWriter(TypeEntry type, SymbolTable symbolTable) { return new NoopWriter(); } public Writer getWriter(Definition definition, SymbolTable symbolTable) { return new NoopWriter(); } public void setEmitter(Emitter emitter) {} } 1.9 +17 -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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Java2WsdlAntTask.java 18 Feb 2002 17:11:49 -0000 1.8 +++ Java2WsdlAntTask.java 20 Feb 2002 17:17:36 -0000 1.9 @@ -58,6 +58,9 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.axis.encoding.TypeMapping; +import org.apache.axis.encoding.DefaultTypeMappingImpl; +import org.apache.axis.encoding.DefaultSOAP12TypeMappingImpl; import java.util.HashMap; import java.io.StringWriter; @@ -81,6 +84,7 @@ private boolean useInheritedMethods = false; private String exclude = null; private String stopClasses = null; + private String tm = "1.1"; // The method executing the task public void execute() throws BuildException { @@ -96,6 +100,7 @@ log("\tinheritance:" + useInheritedMethods, Project.MSG_VERBOSE); log("\texcluded:" + exclude, Project.MSG_VERBOSE); log("\tstopClasses:" + stopClasses, Project.MSG_VERBOSE); + log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE); // Instantiate the emitter Emitter emitter = new Emitter(); @@ -115,6 +120,13 @@ emitter.setDisallowedMethods(exclude); if (stopClasses != null) emitter.setStopClasses(stopClasses); + + if (tm.equals("1.1")) { + emitter.setDefaultTypeMapping(DefaultTypeMappingImpl.create()); + } else { + emitter.setDefaultTypeMapping(DefaultSOAP12TypeMappingImpl.create()); + } + emitter.setIntfNamespace(namespace); emitter.setLocationUrl(location); emitter.setUseInheritedMethods(useInheritedMethods); @@ -182,6 +194,11 @@ Mapping pkg = new Mapping(); return pkg; } + + // The setter for the "typeMappingVersion" attribute + public void setTypeMappingVersion(String parameter) { + this.tm = parameter; + } /** * Used for nested package definitions. 1.18 +8 -0 xml-axis/java/test/wsdl/Wsdl2javaAntTask.java Index: Wsdl2javaAntTask.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaAntTask.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- Wsdl2javaAntTask.java 7 Feb 2002 14:21:47 -0000 1.17 +++ Wsdl2javaAntTask.java 20 Feb 2002 17:17:36 -0000 1.18 @@ -82,6 +82,7 @@ private String output = "." ; private String deployScope = ""; private String url = ""; + private String tm = "1.2"; // The method executing the task public void execute() throws BuildException { @@ -96,6 +97,7 @@ log("\tdeployScope:" + deployScope, Project.MSG_VERBOSE); log("\tURL:" + url, Project.MSG_VERBOSE); log("\tall:" + all, Project.MSG_VERBOSE); + log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE); // Instantiate the emitter WSDL2Java emitter = new WSDL2Java(); @@ -124,6 +126,7 @@ emitter.setOutputDir(output); emitter.generateSkeleton(skeleton); emitter.verbose(verbose); + emitter.setTypeMappingVersion(tm); Document doc; @@ -190,6 +193,11 @@ // The setter for the "all" attribute public void setAll(String parameter) { this.all = Project.toBoolean(parameter); + } + + // The setter for the "typeMappingVersion" attribute + public void setTypeMappingVersion(String parameter) { + this.tm = parameter; } /** the command arguments */ 1.75 +1 -0 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.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- Wsdl2javaTestSuite.xml 20 Feb 2002 13:46:08 -0000 1.74 +++ Wsdl2javaTestSuite.xml 20 Feb 2002 17:17:36 -0000 1.75 @@ -35,6 +35,7 @@ skeleton="yes" noimports="no" verbose="no" + typeMappingVersion="1.1" testcase="no"> <mapping namespace="urn:AddressFetcher2" package="samples.addr"/> </wsdl2java>