Hi, The -xc option to java2wsdl seems to have stopped working in 1.5, but the option is still reported in the help message for java2wsdl, so this doesn't seem intentional. I have added this to JIRA as AXIS2-4382.
The code that processed the extra classes seems to have been removed from DefaultSchemaGenerator. The attached patch restores the handling of extra classes. The code differs quite a lot from the original, since all the surrounding code has changed so much, but I think it captures the intent. Regards, Pétur Runólfsson Betware The content of this e-mail, together with any of its attachments, is for the exclusive and confidential use of the named addressee(s) and it may contain legally privileged and confidential information and/or copyrighted material. Any other distribution, use or reproduction without the sender's prior consent is unauthorized and strictly prohibited. If you have by coincidence, mistake or without specific authorization received this e-mail in error, please notify the sender by e-mail immediately, uphold strict confidentiality and neither read, copy, transfer, disseminate, disclose nor otherwise make use of its content in any way and delete the material from your computer. The content of the e-mail and its attachments is the liability of the individual sender, if it does not relate to the affairs of Betware. Betware does not assume any civil or criminal liability should the e-mail or it´s attachments be virus infected.
Index: test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java =================================================================== --- test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java (revision 0) +++ test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java (revision 0) @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.axis2.description.java2wsdl; + +import org.apache.axis2.description.AxisService; +import org.apache.ws.commons.schema.XmlSchema; + +import junit.framework.TestCase; + +import javax.xml.namespace.QName; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class DefaultSchemaGeneratorTest extends TestCase { + + public static class TestWebService { + + } + + public static class ExtraClass { + + } + + public void testGeneratesExtraClass() throws Exception { + + AxisService axisService = new AxisService(); + + DefaultSchemaGenerator generator = new DefaultSchemaGenerator(getClass().getClassLoader(), + TestWebService.class.getName(), "http://example.org", "ex", axisService); + ArrayList extraClasses = new ArrayList(); + extraClasses.add(ExtraClass.class.getName()); + generator.setExtraClasses(extraClasses); + + Collection schemaColl = generator.generateSchema(); + assertEquals(1, schemaColl.size()); + XmlSchema schema = (XmlSchema) schemaColl.iterator().next(); + + boolean foundExtra = false; + Iterator names = schema.getElements().getNames(); + while (names.hasNext()) { + QName name = (QName) names.next(); + if (name.getLocalPart().equals("ExtraClass")) + foundExtra = true; + } + assertTrue(foundExtra); + } +} Index: src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java =================================================================== --- src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (revision 785139) +++ src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (working copy) @@ -254,6 +254,14 @@ } classModel= JAXRSUtils.getClassModel(serviceClass); methods = processMethods(serviceClass.getDeclaredMethods()); + + for (Object extra : getExtraClasses()) { + Class extraClass = Class.forName((String) extra, true, classLoader); + if (typeTable.getSimpleSchemaTypeName(extraClass.getName()) == null) { + generateSchema(extraClass); + } + } + return schemaMap.values(); }
