Barnabas Bodnar created CXF-6783: ------------------------------------ Summary: ReflectionServiceFactoryBean generates invalid WSDL if anonymousWrapperTypes==true Key: CXF-6783 URL: https://issues.apache.org/jira/browse/CXF-6783 Project: CXF Issue Type: Bug Components: Services Affects Versions: 3.1.5 Reporter: Barnabas Bodnar Priority: Minor
ReflectionServiceFactoryBean has the public property _anonymousWrapperTypes_ controlling whether the type (XSD) of a message is represented as standalone, named type in the WSDL, or an anonymous, inline type (the default is _false_, also standalone, named). Setting it to _true_ effectuates producing the inline, anonymous type, but this is, however, present also on top-level, as standalone one, making the WSDL invalid (top-level types must have a name): {code:xml} <wsdl:definitions> <wsdl:types> <xsd:schema> <xsd:element name="m"> <xsd:complexType> <xsd:sequence> <xsd:element name="x" type="xsd:int"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType> <xsd:sequence> <xsd:element name="x" type="xsd:int"/> </xsd:sequence> </xsd:complexType> ... </xsd:schema> ... </wsdl:types> ... <wsdl:definitions> {code} Correctly: {code:xml} <wsdl:definitions> <wsdl:types> <xsd:schema> <xsd:element name="m"> <xsd:complexType> <xsd:sequence> <xsd:element name="x" type="xsd:int"/> </xsd:sequence> </xsd:complexType> </xsd:element> ... </xsd:schema> ... </wsdl:types> ... <wsdl:definitions> {code} Fix-proposal: use *new XmlSchemaComplexType(schema, !isAnonymousWrapperTypes())* in the line 1300 instead of *new XmlSchemaComplexType(schema, true)*. {code:title=rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ReflectionServiceFactoryBean.java|borderStyle=solid} 1289 private void createWrappedMessageSchema(ServiceInfo serviceInfo, AbstractMessageContainer wrappedMessage, 1290 AbstractMessageContainer unwrappedMessage, SchemaInfo info, 1291 QName wrapperName) { 1292 1293 XmlSchema schema = info.getSchema(); 1294 info.setElement(null); // the cached schema will be no good 1295 XmlSchemaElement el = new XmlSchemaElement(schema, true); 1296 el.setName(wrapperName.getLocalPart()); 1297 1298 wrappedMessage.getFirstMessagePart().setXmlSchema(el); 1299 1300 XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, true); 1301 1302 if (!isAnonymousWrapperTypes()) { 1303 ct.setName(wrapperName.getLocalPart()); 1304 el.setSchemaTypeName(wrapperName); 1305 } 1306 el.setSchemaType(ct); {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)