ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Veilleux (JIRA)" <>
Subject [jira] Commented: (AXIS2-4356) WSDL2Java doesn't support xsd:element@fixed
Date Fri, 28 May 2010 16:13:37 GMT


Eric Veilleux commented on AXIS2-4356:

  I did a change to the class in my local environment to support the use
of fixed attributes.

  My patch consisted of reading the values of the "fixed"  attributes of the WSDL and pumping
them in the mechanism that ADB already had to handle default values of attribute.  So after
all is said and done, the result will be that your generated classes will now define the attribute
and initialize them to the proper values.

I add these lines to SchemaCompiler at 1926

// set the default value
          if(att.getDefaultValue() != null)   {
                metainf.registerDefaultValue(att.getQName(), att.getDefaultValue());

// Added to support fixed values on attributes.
        if(att.getFixedValue() != null)   {
            metainf.registerDefaultValue(att.getQName(), att.getFixedValue());

It's not perfect because the generated class will still allow you to put invalid values in
the attributes after the fact. 

> WSDL2Java doesn't support xsd:element@fixed
> -------------------------------------------
>                 Key: AXIS2-4356
>                 URL:
>             Project: Axis2
>          Issue Type: Improvement
>          Components: adb, codegen, wsdl
>    Affects Versions: 1.4.1
>         Environment: Java 6
>            Reporter: Aaron Gourley
>            Priority: Minor
> For reference, the default and fixed constraints are defined here:
> Consider the following XML schema definitions:
> <xs:element name="ResultCode" type="tns:ResultCode" />
> <xs:complexType name="ResultCode">
>     <xs:sequence>
>         <xs:element name="code" default="0" type="xs:long" />
>     </xs:sequence>
> </xs:complexType>
> <xs:element name="SuccessCode" type="tns:SuccessCode" />
> <xs:complexType name="SuccessCode">
>     <xs:sequence>
>         <xs:element name="code" fixed="0" type="xs:long" />
>     </xs:sequence>
> </xs:complexType>
> ADB code generated for the ResultCode element is correct in setting the default value
of the code field to 0:
>     protected long localCode = org.apache.axis2.databinding.utils.ConverterUtil.convertToLong("0");
> ADB code generated for the SuccessCode element is incorrect according to XSD definition
for the fixed element.  It actually appears to completely ignore the fixed attribute.  Considering
the XSD definition for the fixed attribute, I think the generated code should declare the
code field as final and set the final value as follows:
>     protected final long localCode = org.apache.axis2.databinding.utils.ConverterUtil.convertToLong("0");
> It follows that the generated code should not contain a setter method for the code field.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message