axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl Wsdl2javaTestSuite.xml
Date Tue, 23 Jul 2002 14:02:58 GMT
scheu       2002/07/23 07:02:57

  Modified:    java/src/org/apache/axis/wsdl/fromJava Emitter.java
                        Types.java
               java/test/wsdl Wsdl2javaTestSuite.xml
  Log:
  Fix for Bugzilla Bug 10646:
  When echo?wsdl is requested, the generated wsdl uses xsd:base64Binary
  to describe the echoHexBinary request and response.
  
  Solution:
  
  The root of this problem is line 1070 in the Java2WSDL Emitter.
  The writePartType takes an (javaType, xmlType) pair to write the
  message part.  The Emitter was sending the proper javaType, but
  was sending the name of the element instead of the qname representing
  the type.  The wrong combination of arguments meant that writePartType
  always resorted to intropspecting javaType to determine the
  type to write.  And in this case, a byte[] maps to xsd:base64binary.
  
  Changing the Emitter code to pass in the correct QName fixed the 10646
  bug, but revealed a number of other hidden bugs during testing.
  
  The following additional changes were made:
  
    * Changed the Types:writeType(javaType) method to
      Types:writeType(javaType, qName) so that it could be called
      with both the javaType and xmlType pairing.  Similar change
      to writeTypeNamespace.
  
    * Removed defaulting to the DefaultSOAP12TypeMapping.
  
    * Fixed some problems with the setting up the TypeMapping on
      the temporary ServiceDesc's set up by the Emitter.
  
    * Change the java2wsdl calls for the Roundtrip testcase to
      use the appropriate typeMappingVersion.
  
  Revision  Changes    Path
  1.53      +24 -19    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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Emitter.java	20 Jul 2002 00:30:20 -0000	1.52
  +++ Emitter.java	23 Jul 2002 14:02:57 -0000	1.53
  @@ -377,14 +377,23 @@
        */
       private void init(int mode) {
   
  +        // Get a default TM if not specified.
  +        if (defaultTM == null) {
  +            defaultTM = DefaultTypeMappingImpl.getSingleton();
  +        }
  +
           // 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());
  +
  +            // Set the typeMapping to the one provided.
  +            // If not available use the default TM
  +            if (tm != null) {
  +                serviceDesc.setTypeMapping(tm);
  +            } else {
  +                serviceDesc.setTypeMapping(defaultTM);
  +            }
           }
   
           serviceDesc.setStopClasses(stopClasses);
  @@ -400,9 +409,14 @@
               serviceDesc2 == null) {
               serviceDesc2 = new ServiceDesc();
               serviceDesc2.setImplClass(implCls);
  -            TypeMappingRegistry tmr = new TypeMappingRegistryImpl();
  -            serviceDesc2.setTypeMapping((TypeMapping)
  -                                       tmr.getDefaultTypeMapping());
  +
  +            // Set the typeMapping to the one provided.
  +            // If not available use the default TM
  +            if (tm != null) {
  +                serviceDesc2.setTypeMapping(tm);
  +            } else {
  +                serviceDesc2.setTypeMapping(defaultTM);
  +            }
               serviceDesc2.setStopClasses(stopClasses);
               serviceDesc2.setAllowedMethods(allowedMethods);
               serviceDesc2.setDisallowedMethods(disallowedMethods);
  @@ -452,16 +466,7 @@
               
               encodingList = new ArrayList();
               encodingList.add(Constants.URI_DEFAULT_SOAP_ENC);
  -
  -
  -            // We want to produce valid SOAP 1.2 JAX-RPC
  -            // translations, so make sure that the default type mapping
  -            // is for SOAP 1.2.
  -            if (defaultTM == null ||
  -                defaultTM instanceof DefaultTypeMappingImpl) {
  -                defaultTM = DefaultSOAP12TypeMappingImpl.create();
  -            }
  -
  +            
               if (intfNS == null) {
                   Package pkg = cls.getPackage();
                   intfNS = namespaces.getCreate(
  @@ -1067,9 +1072,9 @@
           QName elemQName = null;
           if (mode != MODE_RPC)
               elemQName = param.getQName();
  -        QName typeQName = types.writePartType(javaType,
  -                elemQName); 
           if (mode == MODE_RPC) {
  +            QName typeQName = types.writePartType(javaType,
  +                                                  param.getTypeQName()); 
               if (typeQName != null) {
                   part.setTypeName(typeQName);
                   part.setName(param.getName());
  
  
  
  1.47      +28 -17    xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- Types.java	16 Jul 2002 22:42:51 -0000	1.46
  +++ Types.java	23 Jul 2002 14:02:57 -0000	1.47
  @@ -188,7 +188,6 @@
           // Create a symbol table and populate it with the input wsdl document
           BaseTypeMapping btm = 
               new BaseTypeMapping() {
  -                TypeMapping defaultTM = DefaultTypeMappingImpl.getSingleton();
                       public String getBaseName(QName qNameIn) {
                           QName qName = new QName(
                                 qNameIn.getNamespaceURI(),                              
  
  @@ -248,16 +247,15 @@
               type = JavaUtils.getHolderValueType(type);
           }
           if (isSimpleType(type)) {
  -            QName typeQName = getTypeQName(type);
               // Still need to write any element declaration...
               if (qname != null) {
  -                String elementType = writeType(type);
  +                String elementType = writeType(type, qname);
                   Element element = createElementDecl(qname, elementType, false);
                   if (element != null) {
                       writeSchemaElement(qname,element);
                   }
               }
  -            return typeQName;
  +            return qname;
           }else {
               if (wsdlTypesElem == null) {
                   writeWsdlTypesElement();
  @@ -272,11 +270,12 @@
        * @return the QName of the generated Element
        */
       private QName writeTypeAsElement(Class type, QName qName) throws AxisFault {
  -        QName typeQName = writeTypeNamespace(type);
  -        if (qName == null) {
  -            qName = typeQName;
  +        if (qName == null ||
  +            Constants.equals(Constants.SOAP_ARRAY, qName)) {
  +            qName = getTypeQName(type);
           }
  -        String elementType = writeType(type);
  +        QName typeQName = writeTypeNamespace(type, qName);
  +        String elementType = writeType(type, qName);
           if (elementType != null) {
               Element element = createElementDecl(qName, elementType, isNullable(type));
               if (element != null)
  @@ -291,13 +290,17 @@
        * given <code>Class</code>
        *
        * @param type input Class
  +     * @param qName qname of the Class
        * @return QName for the schema type representing the class
        */
  -    private QName writeTypeNamespace(Class type) {
  -        QName qName = getTypeQName(type);
  +    private QName writeTypeNamespace(Class type, QName qName) {
  +        if (qName == null) {
  +            qName = getTypeQName(type);
  +        }
           String pref = def.getPrefix(qName.getNamespaceURI());
           if (pref == null)
  -          def.addNamespace(namespaces.getCreatePrefix(qName.getNamespaceURI()), qName.getNamespaceURI());
  +          def.addNamespace(namespaces.getCreatePrefix(qName.getNamespaceURI()),
  +                           qName.getNamespaceURI());
           return qName;
       }
   
  @@ -455,13 +458,21 @@
        * Then return the qualified string representation of the generated type
        *
        * @param type Class for which to generate schema
  +     * @param qname of the type to write
        * @return a prefixed string for the schema type
        */
       public String writeType(Class type) throws AxisFault {
  +        return writeType(type, null);
  +    }
  +    public String writeType(Class type, QName qName) throws AxisFault {
  +        // Get a corresponding QName if one is not provided
  +        if (qName == null ||
  +            Constants.equals(Constants.SOAP_ARRAY, qName)) {
  +            qName = getTypeQName(type);
  +        }
   
           // Quick return if schema type
           if (isSimpleType(type)) {
  -            QName qName = getTypeQName(type);
               if (Constants.isSchemaXSD(qName.getNamespaceURI())) {
                   return Constants.NS_PREFIX_SCHEMA_XSD + ":" +
                       qName.getLocalPart();
  @@ -484,7 +495,7 @@
           // if applicable, otherwise issue errors and return anyType
           if (factory == null) {
               if (isBeanCompatible(type, true)) {
  -                factory = new BeanSerializerFactory(type, getTypeQName(type));
  +                factory = new BeanSerializerFactory(type, qName);
               } else {
                   return Constants.NS_PREFIX_SCHEMA_XSD + ":" +
                       Constants.XSD_ANYTYPE.getLocalPart();
  @@ -501,8 +512,8 @@
                       JavaUtils.getMessage("NoSerializer00", type.getName()));
           }
   
  -          // Write the namespace
  -        QName qName = writeTypeNamespace(type);
  +        // Write the namespace
  +       writeTypeNamespace(type, qName);
   
           // If an array the component type should be processed first
           String componentTypeName = null;
  @@ -516,7 +527,7 @@
                       componentType = componentType.getComponentType();
                   }
               }
  -            componentTypeName = writeType(componentType) + dimString;
  +            componentTypeName = writeType(componentType, null) + dimString;
           }
   
           String soapTypeName = qName.getLocalPart();
  @@ -618,7 +629,7 @@
           simpleType.setAttribute("name", qName.getLocalPart());
           Element restriction = docHolder.createElement("restriction");
           simpleType.appendChild(restriction);
  -        String baseType = writeType(base);
  +        String baseType = writeType(base, null);
           restriction.setAttribute("base", baseType);
   
           // Create an enumeration using the field values
  
  
  
  1.116     +4 -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.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- Wsdl2javaTestSuite.xml	22 Jul 2002 19:09:04 -0000	1.115
  +++ Wsdl2javaTestSuite.xml	23 Jul 2002 14:02:57 -0000	1.116
  @@ -196,6 +196,7 @@
         <exclude name="test/wsdl/roundtrip/*Impl.java" />
       </javac>
   
  +
       <!-- The following invocation of java2wsdl simply tests whether the 
            split wsdl function works.  The generated wsdl files are not used. -->
       
  @@ -205,6 +206,7 @@
                  useInheritedMethods="false"
                  namespace="http://roundtrip.wsdl.test"
                  namespaceImpl="http://roundtrip.wsdl.test"
  +               typeMappingVersion="1.2"
                  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"/>
  @@ -216,6 +218,7 @@
                  className= "test.wsdl.roundtrip.RoundtripPortType"
                  useInheritedMethods="false"
                  namespace="http://roundtrip.wsdl.test"
  +               typeMappingVersion="1.2"
                  location="http://localhost:8080/axis/services/RoundtripTest">
           <mapping namespace="http://roundtrip.wsdl.test" package="test.wsdl.roundtrip"/>
       </java2wsdl>
  @@ -228,6 +231,7 @@
                  className= "test.wsdl.roundtrip.RoundtripPortType"
                  useInheritedMethods="false"
                  namespace="http://roundtrip.wsdl.test"
  +               typeMappingVersion="1.2"
                  location="http://localhost:8080/axis/services/RoundtripTest2">
           <mapping namespace="http://roundtrip.wsdl.test" package="test.wsdl.roundtrip"/>
       </java2wsdl>
  
  
  

Mime
View raw message