Discussion:
Migrating from Axis 1.x to Axis2: Java2WSDLTask: boolean getters
vlad romascanu
2018-04-18 23:10:10 UTC
Permalink
Hello,

I'm migrating from Axis 1.4 to Axis2 1.7.7.  I have observed that for
the following WSDL:

...
    <types>
        <schema elementFormDefault="qualified"
            targetNamespace="..."
            xmlns="http://www.w3.org/2001/XMLSchema">
...
            <complexType name="HostType">
                <sequence>
...
                    <element minOccurs="1" maxOccurs="1"
                        name="SSLEnabled" type="boolean" />
...
                </sequence>
            </complexType>
...

Axis 1.4's wsdl2java ANT task (output, testcase="false", serverside,
url, mapping options) generated:

    /**
     * Gets the SSLEnabled value for this HostType.
     *
     * @return SSLEnabled
     */
    public boolean isSSLEnabled() {
        return SSLEnabled;
    }

whereas Axis2 1.7.7's ANT task (output, testcase="false",
syncOnly="false", serverSide, wsdlfilename, generateServiceXml options)
now generates:

    /**
     * Auto generated getter method
     * @return boolean
     */
    public boolean getSSLEnabled() {
        return localSSLEnabled;
    }

Notice how the old isXXX() has become getXXX().

I couldn't find this addressed on this list or elsewhere.

Is this change expected behaviour, and is it controllable in any way?

Thanks,
V.
vlad romascanu
2018-04-19 16:51:18 UTC
Permalink
To answer my own question:

Code generation in Axis 1.x was in this case handled by
org.apache.axis.wsdl.toJava.JavaBeanWriter:

public class JavaBeanWriter extends JavaClassWriter {
...
    /**
     * Writes the setter and getter methods
     */
    protected void writeAccessMethods() {
...
            String get = "get";

            if (typeName.equals("boolean")) {
                get = "is";
            }
...

...whereas in Axis2 the ADB generator is using XSLT with no special
provision for booleans:

/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl:/
...
                          /**
                          * Auto generated getter method
                          * @return <xsl:value-of
select="$propertyType"/>
                          */
                          public  <xsl:value-of
select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of
select="$javaName"/>(){
                              return <xsl:value-of select="$varName"/>;
                          }
...
Post by vlad romascanu
Notice how the old isXXX() has become getXXX().
I couldn't find this addressed on this list or elsewhere.
Is this change expected behaviour, and is it controllable in any way?
Thanks,
V.
Loading...