You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Marco Benuzzi (JIRA)" <ji...@apache.org> on 2011/08/03 12:00:28 UTC

[jira] [Created] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

optional attribute must not be serialized if not explicitly set
---------------------------------------------------------------

                 Key: AXIS2-5109
                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
             Project: Axis2
          Issue Type: Bug
          Components: adb
    Affects Versions: 1.6.0
         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
            Reporter: Marco Benuzzi
            Priority: Critical


All the attributes are serialized with default values even if they are not explicitly set.
This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.

<xs:complexType name="Sample">
  <xs:sequence />
  <xs:attribute name="BooleanAttribute" type="xs:boolean" />
  <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
  <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
</xs:complexType>

If I don't set any attribute the generated xml look like

<Sample BooleanAttribute="false" IntAttribute="0"/>

This is completely wrong because the default values for my optional attributes can be different.
It should be (please remember that - as per specification - all attributes are optional by default)

<Sample/>

The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
if (localAge != java.lang.Integer.MIN_VALUE) {
   writeAttribute("",
    "IntAttribute",
   org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);

But for xs:boolean attribute there is no workaround because in serialization the code is
if (true) {
   writeAttribute("",
    "BooleanAttribute",
   org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);

                                      }



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Comment: was deleted

(was: ./modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>         Attachments: ADBBeanTemplate-bean.xsl, AttributeTest.java
>
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Comment: was deleted

(was: I've tried to use java primitive type wrapper (Integer, Boolean, etc) instead of simple primitive for attributes.
In the serialization I write the attribute only if it is not null.

Attached the two files I modified.
* modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
* modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java

For me it works.)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment:     (was: AttributeTest.java)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Comment: was deleted

(was: ./modules/adb-codegen/src/org/apache/axis2/schema/template/)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment:     (was: ADBBeanTemplate-bean.xsl)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment: ADBBeanTemplate-bean.xsl

./modules/adb-codegen/src/org/apache/axis2/schema/template/

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>         Attachments: ADBBeanTemplate-bean.xsl
>
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment:     (was: AttributeTest.java)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment: ADBBeanTemplate-bean.xsl
                AttributeTest.java

I've tried to use java primitive type wrapper (Integer, Boolean, etc) instead of simple primitive for attributes.
In the serialization I write the attribute only if it is not null.

Attached the two files I modified.
* modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
* modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java

For me it works.

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>         Attachments: ADBBeanTemplate-bean.xsl, AttributeTest.java
>
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment:     (was: ADBBeanTemplate-bean.xsl)

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[jira] [Updated] (AXIS2-5109) optional attribute must not be serialized if not explicitly set

Posted by "Marco Benuzzi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Benuzzi updated AXIS2-5109:
---------------------------------

    Attachment: AttributeTest.java

./modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java

> optional attribute must not be serialized if not explicitly set
> ---------------------------------------------------------------
>
>                 Key: AXIS2-5109
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5109
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.13-92.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Critical
>         Attachments: ADBBeanTemplate-bean.xsl, AttributeTest.java
>
>
> All the attributes are serialized with default values even if they are not explicitly set.
> This is a problem because the default value of an attribute is a contract between the client and the web service provider and the framework should not override it.
> <xs:complexType name="Sample">
>   <xs:sequence />
>   <xs:attribute name="BooleanAttribute" type="xs:boolean" />
>   <xs:attribute name="IntAttribute" type="xs:int" use="required"/>
>   <xs:attribute name="StringAttribute" type="xs:string" use="optional"/>
> </xs:complexType>
> If I don't set any attribute the generated xml look like
> <Sample BooleanAttribute="false" IntAttribute="0"/>
> This is completely wrong because the default values for my optional attributes can be different.
> It should be (please remember that - as per specification - all attributes are optional by default)
> <Sample/>
> The workaround for xs:int attribute is to explicitly set it to java.lang.Integer.MIN_VALUE because in serialization the code is
> if (localAge != java.lang.Integer.MIN_VALUE) {
>    writeAttribute("",
>     "IntAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIntAttribute), xmlWriter);
> But for xs:boolean attribute there is no workaround because in serialization the code is
> if (true) {
>    writeAttribute("",
>     "BooleanAttribute",
>    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBooleanAttribute), xmlWriter);
>                                       }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org