Rebecca Searls created CXF-6089: ----------------------------------- Summary: XmlAccessorOrder.ALPHABETICAL, Exception.getMessage() duplicate WSDL elements generated Key: CXF-6089 URL: https://issues.apache.org/jira/browse/CXF-6089 Project: CXF Issue Type: Bug Affects Versions: 2.7.13 Reporter: Rebecca Searls
When presented with a custom exception class with a XmlAccessorOrder.ALPHABETICAL annotation attribute the Exception.getMessage() method is listed twice as an element in a generated WSDL. The cause of duplicate message elements being listed in the generated WSDL is a duplication of the processing of "cls" by Utils.getGetters at line 562 and addExceptionMessage() at line 587. Utils.getGetters checks for an Exception class defining method, getMessage. If method, "getMessage" is NOT annotated with @XmlTransient it is returned as a method to be processed and added to "seq" (lines 575-581) . A similar evaluation is performed by addExceptionMessage(). It adds a second ref to "getMessage" to "seq" when @XmlTransient is not present on the method, hence the duplicate elements in the WSDL. This same basic code exists back to version (2.6.x-fixes) http://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes I did not check version prior to that. ----- org.apache.cxf.jaxb.JAXBSchemaInitializer 562 for (Method m : Utils.getGetters(cls, accessType)) { .......... 575 JAXBBeanInfo beanInfo = getBeanInfo(type); 576 if (beanInfo != null) { 577 int idx = m.getName().startsWith("get") ? 3 : 2; 578 String name = m.getName().substring(idx); 579 name = Character.toLowerCase(name.charAt(0)) + name.substring(1); 580 XmlElement xmlElementAnno = m.getAnnotation(XmlElement.class); 581 addElement(schema, seq, beanInfo, new QName(namespace, name), isArray(type), xmlElementAnno); } } } // Create element in xsd:sequence for Exception.class if (Exception.class.isAssignableFrom(cls)) { 587 addExceptionMessage(cls, schema, seq); } ----- org.apache.cxf.jaxb.JAXBSchemaInitializer private void addExceptionMessage(Class<?> cls, XmlSchema schema, XmlSchemaSequence seq) { try { //a subclass could mark the message method as transient 611 Method m = cls.getMethod("getMessage"); 612 if (!m.isAnnotationPresent(XmlTransient.class)) { JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class); XmlSchemaElement exEle = new XmlSchemaElement(schema, false); exEle.setName("message"); exEle.setSchemaTypeName(getTypeName(beanInfo)); exEle.setMinOccurs(0); 618 seq.getItems().add(exEle); } } catch (Exception e) { //ignore, just won't have the message element } ----- org.apache.cxf.jaxb.Utils 121 if (method.isBridge() 122 || Modifier.isStatic(method.getModifiers()) 123 >> || method.isAnnotationPresent(XmlTransient.class) 124 || method.getDeclaringClass().equals(Throwable.class) 125 || "getClass".equals(method.getName())) { 126 return false; } -- This message was sent by Atlassian JIRA (v6.3.4#6332)