简体   繁体   中英

What does `extra classes` parameter from `Java2WSDL` do?

Does anyone know what extra classes parameter from Java2WSDL tool mean?

Java2DSDL Reference

I am looking to answer this question , but have no success.

It is used to include those types in WSDL definition whose parents appears as return types or parameters. Consider very simple example:

public class DemoService {
    public Animal pickRandomAnimal() {
        return new Dog(); // or any other animal
    }
}

.. where Animal is an interface. At a WSDL generation time Axis2 will not be able to automatically trace all possible implementations of Animal that you might expect to be returned. Without extraClasses you'll get something like this:

    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://demo.com/xsd">
        <xs:complexType name="Animal">
            <xs:sequence>
                <xs:element minOccurs="0" name="animalName" nillable="true" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:schema>

.. and if you add extraClasses="com.demo.Dog", you'll cover all types you need in your WSDL schema part:

    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://demo.com/xsd">
        <xs:complexType name="Animal">
            <xs:sequence>
                <xs:element minOccurs="0" name="animalName" nillable="true" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Dog">
            <xs:sequence>
                <xs:element minOccurs="0" name="animalName" nillable="true" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:schema>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM